Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2012
    Posts
    412
    Plugin Contributions
    0

    Default Main page javascript

    I'm trying to install some javascript in the html that creates the main page. The script must be placed in the html head (before the </head> for the main page, but I'm struggling to find out where that html exists. In addition, I need to condition adding the javascript based on a variable I've created. I'm trying to integrate a cookie disclosure script that will display a cookie use disclosure the first time a user goes to the home page for EU GDPR.

    If I put the javascript in the includes/modules/pages/index folder, I assume the javascript will be made available for the main page, but where can I add the test that conditionally adds the script to the html?

    Thanks in advance for steering me to the correct file.

  2. #2
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: Main page javascript

    The JavaScript should be renamed, to jscript_YOURSCRIPT. And should be placed in includes/templates/YOUR_TEMPLATE/ jscript. This way it loads on every page, and not only on the main page. Most visitors will never see your main page but go straight to the product page.

  3. #3
    Join Date
    Jun 2012
    Posts
    412
    Plugin Contributions
    0

    Default Re: Main page javascript

    Good idea Design75. Thanks! Implemented my php conditional (if-else structure) in my javascript file, named it jscript_[myscriptname].php and put it in the location you suggested. Works great. I'm constantly amazed at the flexibility of the Zen Cart framework. Great work developers!

  4. #4
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: Main page javascript

    Thank for reporting back.
    BTW which script are you using?

  5. #5
    Join Date
    Jun 2012
    Posts
    412
    Plugin Contributions
    0

    Default Re: Main page javascript

    I'm using a script from Cookie Consent by Insights. I wrote some observer code to get the users country from their IP address through ipinfo.io, and am using the cookie script to display the informational "cookies used here" message for users in the EU countries. i could probably use the geolocation services in Cookies Consent instead of my observer code, but the javascript to do so is a bit above my capabilities.

  6. #6
    Join Date
    Mar 2016
    Location
    Norcatur, Kansas, USA
    Posts
    80
    Plugin Contributions
    3

    Default Re: Main page javascript

    Quote Originally Posted by Dave224 View Post
    I'm using a script from Cookie Consent by Insights. I wrote some observer code to get the users country from their IP address through ipinfo.io, and am using the cookie script to display the informational "cookies used here" message for users in the EU countries. i could probably use the geolocation services in Cookies Consent instead of my observer code, but the javascript to do so is a bit above my capabilities.
    How does this work for users who are using a VPN to mask their actual location?

  7. #7
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: Main page javascript

    Quote Originally Posted by Fjolsvith View Post
    How does this work for users who are using a VPN to mask their actual location?
    That depends on what IP they use. But that is not your problem,if someone chooses to hide his real location.

 

 

Similar Threads

  1. Help Remove catagories off main page, but list subcatagories of main page
    By MadPricerSales in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 26 Mar 2010, 04:14 AM
  2. Javascript on Main Page
    By CharInLasVegas in forum Templates, Stylesheets, Page Layout
    Replies: 10
    Last Post: 10 Dec 2009, 11:50 AM
  3. flash on main page with javascript ASAP
    By MaxBodine in forum General Questions
    Replies: 4
    Last Post: 23 Jul 2009, 03:19 PM
  4. Problems integrating php/javascript on main page
    By webrock in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 23 Jan 2009, 05:20 AM
  5. Calling Javascript file from main page
    By praiseandplay in forum Templates, Stylesheets, Page Layout
    Replies: 10
    Last Post: 5 Aug 2006, 04:41 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR