Results 1 to 10 of 29

Hybrid View

  1. #1
    Join Date
    May 2007
    Location
    SW Florida
    Posts
    1,051
    Plugin Contributions
    2

    Idea or Suggestion 1.3.8a - Where do i add custom js for home page only?

    Which file do I edit to load these .js files for the home page only.

    What PHP syntax would I use to get it to print:
    Code:
    <script type="text/javascript" src="includes/rockslideshow/rokslideshow.js"></script>
    <script type="text/javascript" src="includes/rockslideshow/mootools-release-1.11.js"></script>
    in the header for the home page only?

    THANKS
    JOhn ><>
    Newest Site: ChargerPros - Stuff4Toys

  2. #2
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: 1.3.8a - Where do i add custom js for home page only?

    You would edit /includes/templates/your_template/tpl_header.php.
    PHP Code:
    <?php
    if ($this_is_home_page) { ?>
      <script type="text/javascript" src="includes/rockslideshow/rokslideshow.js"></script>
      <script type="text/javascript" src="includes/rockslideshow/mootools-release-1.11.js"></script>
    <?php 
    ?>

  3. #3
    Join Date
    May 2007
    Location
    SW Florida
    Posts
    1,051
    Plugin Contributions
    2

    Have a Drink Re: 1.3.8a - Where do i add custom js for home page only?

    AWESOME I will be able to try this on my test site tonight. If that works, I will create a mod/add-on for Zen-Cart using http://www.rocketwerx.com/products/r...eshow/overview a really nice little slideshow program.

    JOhn ><>
    Newest Site: ChargerPros - Stuff4Toys

  4. #4
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: 1.3.8a - Where do i add custom js for home page only?

    If you're going to create a contribution/addon, then do it using overrides, without editing core files:

    Don't touch tpl_header.php

    Instead, create a new file to put that code into:
    /includes/templates/YOUR_TEMPLATE/jscript/jscript_my_special_slideshow.php

    You can find more documentation on autoloading javascript in your /docs/ folder and in the wiki.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    May 2007
    Location
    SW Florida
    Posts
    1,051
    Plugin Contributions
    2

    Default Re: 1.3.8a - Where do i add custom js for home page only?

    That worked COOL DrByte.

    My lack of wisdom on this matter is really showing. I created the file like you said, put the code in from gjh42 (THANKS) and it loaded great, I think...

    Still not getting the script to work.

    Take a look http://www.langeshome.com/KERUSSO/ is there a way to tell if the java scripts are actually loading into memory?

    JOhn ><>
    Newest Site: ChargerPros - Stuff4Toys

  6. #6
    Join Date
    Oct 2006
    Posts
    624
    Plugin Contributions
    0

    Default Re: 1.3.8a - Where do i add custom js for home page only?

    Just rename your javascript files to begin with the word 'jscript_' and place them into the respective directories which you want to load either on a per-page or site-wide basis.

    For your case, as you want your javascript to load only for the index/home page, you can do something like this:


    • includes/modules/pages/index/jscript_rokslideshow.js
    • includes/modules/pages/index/jscript_mootools-release-1.11.js


    If done correctly, refresh your browser and go to the store's index/home page and view source. You should see the following two lines of code in the head section of the html.

    HTML Code:
    <script type="text/javascript" src="includes/modules/pages/index/jscript_rokslideshow.js"></script>
    <script type="text/javascript" src="includes/modules/pages/index/jscript_mootools-release-1.11.js"></script>
    As DrByte suggests, you can read more about this in the following file of your Zen Cart installation.


    • docs/read_me_jscript.html
    Goh Koon Hoek, author of "e-Start Your Web Store with Zen Cart".
    Printed book: www.lulu.com/content/10576284
    Electronic book and Errata: www.cucumbermedia.com/store

  7. #7
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: 1.3.8a - Where do i add custom js for home page only?

    Quote Originally Posted by Stuff4Toys View Post
    That worked COOL DrByte.

    My lack of wisdom on this matter is really showing. I created the file like you said, put the code in from gjh42 (THANKS) and it loaded great, I think...

    Still not getting the script to work.

    Take a look http://www.langeshome.com/KERUSSO/ is there a way to tell if the java scripts are actually loading into memory?

    JOhn ><>
    It seems the files are loading properly.

    However, if they're not "doing" anything for you, what are you missing that's supposed to "trigger" something to start some sort of effect?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. How can i create custom center box, for home page only?!?
    By tcarden in forum Customization from the Admin
    Replies: 2
    Last Post: 7 Dec 2012, 07:05 PM
  2. How to show a custom sidebox only on my home page?
    By SandraSD in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 16 Dec 2009, 08:43 AM
  3. Custom Footer for home page
    By jamesdenny in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 7 Feb 2009, 12:32 PM
  4. How do I add custom content to Home page?
    By emilfalcon in forum Basic Configuration
    Replies: 2
    Last Post: 28 Sep 2007, 09:51 PM
  5. Add new content to home page only?
    By purkat in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 17 Aug 2006, 09:43 AM

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