Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Cindy Bidar Posted July 5, 2022 Posted July 5, 2022 Hi There, I added a script which is a popup inside Advanced Configuration==>Page Output==> Body code and it shows everywhere including the login page. I need to hide the popup from that page as the content of the popup is intended for members only. Can you tell me how to exclude the script from loading or hide the popup from the login page. Thank you for your support!
Marc Posted July 5, 2022 Posted July 5, 2022 We would not be able to assist with custom development under support, however I have moved your ticket to our developer connection forum for you.
Nathan Explosion Posted July 5, 2022 Posted July 5, 2022 <script> $(document).ready(function(){ var page = $('body').attr("data-pageController"); if (page != 'login'){ //Your code... } }); </script>
Cindy Bidar Posted July 5, 2022 Author Posted July 5, 2022 Thanks Nathan! I did try your code but it did not work as I get a syntax error when inspecting through Chrome console This the error I see: Uncaught SyntaxError: Unexpected token '<' (at (index):1840:4) I don't think a I can put a script within a script, I think that is what causing the error. The popup script is the following: <div class="popup" id="51f18_16504"></div><script src="https://www.powr.io/powr.js?platform=html"></script> This is how I put it inside the code you provided: <script> $(document).ready(function(){ var page = $('body').attr("data-pageController"); if (page != 'login'){ <div class="popup" id="51f18_16504"></div><script src="https://www.powr.io/powr.js?platform=html"></script> } }); </script> Any idea how I can insert the popup scriot correctly without causing that error? Thank you very much!
Nathan Explosion Posted July 5, 2022 Posted July 5, 2022 OK, I assumed by script you meant javascript code itself. To do that, you'd probably want to put a document.write in there to handle the outputting of the html into the page. Q: what exactly is it that you are trying to achieve? What is in the popup?
Cindy Bidar Posted July 5, 2022 Author Posted July 5, 2022 The popup is just to remind my members with our Q&A call. ( screenshot attached). The poup has text, image and a countdown timer. As you can see from the screenshot attached, I can't have the popup show up in the login page as it contain a link to where members can join the Q&A that is why I want to hide from the login page. How do I put a document.write inside the code you provided? Thanks again for your help, much appreciated.
Nathan Explosion Posted July 5, 2022 Posted July 5, 2022 If the countdown element isn't required, that's an ideal use-case for the new Alerts functionality in IPS 4.7 I'll take another look at options here tomorrow if I get some spare time.
Solution Nathan Explosion Posted July 5, 2022 Solution Posted July 5, 2022 (edited) Give this a try - plugin instead of trying to write some javascript. It will insert this: <div class="popup" id="51f18_16504"></div> <script src="https://www.powr.io/powr.js?platform=html"> ...on every front-end page of your site, apart from the /login page. (NE) Exclude _ hide script from loading in the login page 1.0.0.xml Off to the pub now, back tomorrow. Edited July 5, 2022 by Nathan Explosion
Cindy Bidar Posted July 6, 2022 Author Posted July 6, 2022 7 hours ago, Nathan Explosion said: Give this a try - plugin instead of trying to write some javascript. Nathan, you rock! That was above and beyond and works like a charm. Can I buy you a coffee (or a pint) or something?
Nathan Explosion Posted July 6, 2022 Posted July 6, 2022 No worries - have pinged a PM with my paypal address; coffee today, as a little too much beer last night. Cindy Bidar and Marc 2
Marc Posted July 6, 2022 Posted July 6, 2022 5 minutes ago, Nathan Explosion said: coffee today, as a little too much beer last night. It's the sleep that does it
Recommended Posts