Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,021
    Plugin Contributions
    32

    Default on_load on Home Page Only?

    Hope this is the right place on the forum for this..

    I've read the wiki pages for adding js to zen cart. http://www.zen-cart.com/wiki/index.p...s_-_Javascript.

    I saved the jscript file "jscript_BookFlip-slideshow.js" to this folder /includes/modules/pages/index/

    I created a file named on_load which contained ONLY the onload code to add to the body tag in it. I also saved it to the /includes/modules/pages/index/ folder

    Now this works beautiful on the home page.. However not only does the javascript load on the products/cateories pages, but I also get an error on all the products/cateories pages which is I know is caused by the on_load code being included in the body tag on the products/cateories pages.

    I have a very good idea how to make sure that the javascript only loads on the home page.. what I am unsure about is how to make sure that the on_load code is NOT added to the body tag on the products/cateories pages..

    Any help will be greatly appreciated..

    Links:
    http:// lanikshair . com/ - Home page
    http:// lanikshair . com/index.php?main_page=index&cPath=31 - Sample category page

    http://www.zen-cart.com/forum/showthread.php?t=82028&highlight=on_load+home
    Last edited by DivaVocals; 25 Sep 2009 at 08:11 PM.

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

    Default Re: on_load on Home Page Only?

    You'll have to hard-code some logic to bypass it for the other pages which share the same name.
    It's an ugly hack.

    For example, since you want to *only* use it on the home page, the simplest way is to destroy the ability for it to work at all on other pages.
    Edit your customized tpl_main_page.php file, and change this:
    Code:
      $body_id = ($this_is_home_page) ? 'indexHome' : str_replace('_', '', $_GET['main_page']);
    ?>
    <body id="<?php echo $body_id . 'Body'; ?>"<?php if($zv_onload !='') echo ' onload="'.$zv_onload.'"'; ?>>
    to this, by adding the line shown:
    Code:
      $body_id = ($this_is_home_page) ? 'indexHome' : str_replace('_', '', $_GET['main_page']);
      if ($current_page_base == 'index' && !$this_is_home_page) $zv_onload = '';
    ?>
    <body id="<?php echo $body_id . 'Body'; ?>"<?php if($zv_onload !='') echo ' onload="'.$zv_onload.'"'; ?>>

    v2.0 uses different page names for the home page vs the category and product-listing pages, so this will happen differently then.
    .

    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.

  3. #3
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,021
    Plugin Contributions
    32

    Default Re: on_load on Home Page Only?

    Just what the doctor ordered.. Oh wait.. you are the doctor.. **LOL**

    Thank you very much.. I am gonna give this a whirl.. I will be sure to update my success! (which I am sure is certain..)

  4. #4
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,021
    Plugin Contributions
    32

    Default Re: on_load on Home Page Only?

    This worked perfectly.. Thank you sooo much for the assist!

 

 

Similar Threads

  1. turn off left or right side bar on home page only [and only certain EZ pages]
    By thebigkick in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 1 Jun 2012, 10:23 PM
  2. Only Show on Home Page...
    By sigol in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 5 Jun 2008, 10:47 PM
  3. Header only on Home page
    By asterix in forum Templates, Stylesheets, Page Layout
    Replies: 13
    Last Post: 8 Apr 2008, 09:24 PM
  4. Header ONLY on HOME page
    By Derwin in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 27 Feb 2008, 02:04 AM
  5. Banner on Home page only
    By Cara_m in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 8 Jun 2006, 10:24 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