Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Apr 2011
    Posts
    38
    Plugin Contributions
    0

    Default Need a conditional to add the script_myjsfile.js

    Hey guys so I got the s3Slider working. Seems to be working good so far. However, what I did was I put the jscript files in the includes/modules/pages/index/ directory because I need the files to load in the head when I go to my index.php?main_page=index&cPath=1 in order for the slideshow to work. I only want the slideshow to come up on the categories page so I have put a conditional in the tpl_index_categories.php file in my custom-template directory that says

    if ($GET['cPath'] ==1) {

    Here is the html for my slider
    }

    Okay, so everything works great. You can check it out at
    http://shop.auroraenterprise.com/ind...=index&cPath=1

    but the one itty-bitty problem is that when I go to my home page if you have firebug or any other javascript reader you will notice a little error. Why? because there is no defined html element for the js function to run. Which leads me to the question. How can I only load the particular js files on my index.php?main_page=index&cPath=1 (which is my first category page)? and prevent the script from loading in any other page?

    Thanks in advance,

    TH

  2. #2
    Join Date
    Oct 2006
    Location
    Alberta, Canada
    Posts
    4,571
    Plugin Contributions
    1

    Default Re: Need a conditional to add the script_myjsfile.js

    This path is correct:
    includes/templates/lite_grey/jscript/jscript_jquery-1.5.2.min.js

    If you also upload & name any other jQuery files the same, starting with 'jscript_' then they will automatically be loaded as well; no need to edit any Header tags. Also, if no longer using the easySlider script then make sure to remove the script and any reference to it.


    To get the Slider working on your Home page and Category 1 pages, you can edit your 'includes/templates/lite_grey/common/tpl_main_page.php' to include the following, just after the Breadcrumb code.

    } ?> <!-- eof breadcrumb -->

    <?php
    if ($current_page_base == 'index' and $cPath == '' or $cPath == '1') {

    Here is the html for my slider
    }

    Read the notes within the 'tpl_main_page.php' at top of page for more info, as that is where I got the above include code.

    Make sure though to remove the code from your 'tpl_index_categories.php' file else the s3slider will be loaded twice.

  3. #3
    Join Date
    Apr 2011
    Posts
    38
    Plugin Contributions
    0

    Default Re: Need a conditional to add the script_myjsfile.js

    Quote Originally Posted by Website Rob View Post
    Also, if no longer using the easySlider script then make sure to remove the script and any reference to it.
    ^Still using the easySlider on my home page, but using s3Slider on categories page. Why? Idk, for variety purposes I guess and to give a different look (i'm going to replace the pics on my category page those are just placeholders for now).


    To get the Slider working on your Home page and Category 1 pages, you can edit your 'includes/templates/lite_grey/common/tpl_main_page.php' to include the following, just after the Breadcrumb code.
    ^I've got the sliders where I want them respectfully, however, the problem lies within the fact that I only want the specific js files to load on certain pages. For instance, I only want the jscript_s3slider.js file to load on the index?main_page=index&cpath=1 page rather than loading on all of the index pages. The jscript_s3slider.js file lives in includes/modules/pages/index/ directory.

    Everything else has been working great. Thanks for the s3Slider lookup

  4. #4
    Join Date
    Oct 2006
    Location
    Alberta, Canada
    Posts
    4,571
    Plugin Contributions
    1

    Default Re: Need a conditional to add the script_myjsfile.js

    If you only want to load on Home page then change my above to use:

    if ($this_is_home_page) {

  5. #5
    Join Date
    Apr 2011
    Posts
    38
    Plugin Contributions
    0

    Default Re: Help with Jquery

    I think I am confusing you.

    I have the html loading where I want it. However, my question is how do you specify when to load a <script src=""></script> into the header of the zen cart. I know there is a way to do this somehow by creating a php file in includes/modules/pages/(whatever page you want the js files to load in, in this example it is index)index/special_php_file.php

    The reason I'm getting a js error on my homepage is because there is no <div id=slider1>... which is good because I don't want to use that on the home page! I'm using the easySlider on the home page and the s3Slider on the categories page

    Is my question more clearly stated?
    Last edited by tthenne; 22 Apr 2011 at 06:26 PM.

  6. #6
    Join Date
    Oct 2006
    Location
    Alberta, Canada
    Posts
    4,571
    Plugin Contributions
    1

    Default Re: Help with Jquery

    I think a review is in order.

    --------------------------------------------------

    This path is correct:
    includes/templates/lite_grey/jscript/jscript_jquery-1.5.2.min.js

    If you also upload & name any other jQuery files the same, starting with 'jscript_' then they will automatically be loaded as well; no need to edit any Header tags.

    To get the Slider working on your Home page and Category 1 pages, you can edit your 'includes/templates/lite_grey/common/tpl_main_page.php' to include the following, just after the Breadcrumb code.

    } ?> <!-- eof breadcrumb -->

    <?php
    if ($current_page_base == 'index' and $cPath == '' or $cPath == '1') {

    Here is the html for my slider
    }

    --------------------------------------------------

    If you only want to load on Home page then change my above to use:

    } ?> <!-- eof breadcrumb -->

    <?php
    if ($this_is_home_page) {

    Here is the html for my slider - or anything else you want on the home page

    }

    --------------------------------------------------

    Not sure why you seem to be stuck on using a more complicated method but the above is easier and will work as desired.

 

 

Similar Threads

  1. Dropdown Menu With jquery
    By Hell Guapo in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 28 Nov 2011, 08:42 PM
  2. SSL Issue with jQuery
    By contrive.it in forum General Questions
    Replies: 3
    Last Post: 23 Aug 2011, 07:13 AM
  3. HELP with Automatic Image Slider w/ CSS & jQuery
    By lucianman in forum General Questions
    Replies: 3
    Last Post: 20 Feb 2011, 10:54 PM
  4. Jquery flash help
    By NYsista872 in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 8 Apr 2010, 08:02 PM
  5. Help Calling JQuery?!
    By tjohnson13 in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 9 Dec 2009, 06:24 PM

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