Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Jan 2009
    Location
    Vegas Baby!
    Posts
    332
    Plugin Contributions
    0

    Default Javascript on Main Page

    This is kind of a dumb-dumb question

    I want to use a dhtml slideshow from dynamic drive on my main page.

    Code:
    Step 1: Insert the below style sheet in the HEAD section of your page:
    
    <style type="text/css">
    
    /*set CSS for SPAN tag surrounding each image*/
    .seqslidestyle{
    margin-right: 15px;
    }
    </style>
    On WHICH page am I inserting this code (includes/languages/english/index.php???) , and WHERE exactly does it go? Do I put it before the opening <?php on the page or somewhere else?

    This is the script I'm looking at using:
    http://www.dynamicdrive.com/dynamici...frameslide.htm
    Completed: BellaFavori.com
    In Progress: WeddingDivasLV.com
    Coming Soon: ???

  2. #2
    Join Date
    Jan 2009
    Location
    Vegas Baby!
    Posts
    332
    Plugin Contributions
    0

    Default Re: Javascript on Main Page

    Ok, I think I got but it's not working very well. Guess it just needs some tweaking.
    Last edited by CharInLasVegas; 22 Oct 2009 at 05:16 AM.
    Completed: BellaFavori.com
    In Progress: WeddingDivasLV.com
    Coming Soon: ???

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

    Default Re: Javascript on Main Page

    Try just adding the style rule to your stylesheet:
    Code:
    /*set CSS for SPAN tag surrounding each image*/
    .seqslidestyle{
    margin-right: 15px;
    }
    Embedding the styling in a file is only necessary if you don't have an external stylesheet.

  4. #4
    Join Date
    Jan 2009
    Location
    Vegas Baby!
    Posts
    332
    Plugin Contributions
    0

    Default Re: Javascript on Main Page

    Thanks, Glenn. I'm going to have to scratch this idea anyway, this slideshow doesn't work well & I can't find any other that shows multiple frames at the same time.
    Completed: BellaFavori.com
    In Progress: WeddingDivasLV.com
    Coming Soon: ???

  5. #5
    Join Date
    Sep 2007
    Posts
    47
    Plugin Contributions
    0

    Default Re: Javascript on Main Page

    I too am wanting a slide-show on the main page (only one frame though), and have got this running OK, except I can only load the additional jscript globally but I need it to only run on the main page. I can't get my head around the template system here, so any advise would be greatly appreciated. To get the additional javascript to load I have modded a template driven file:

    includes/templates/MY_TEMPLATE/common/html_header.php

    and hard-coded the links to the script files that are residing in:

    /includes/templates/MY_TEMPLATE/jscript/

    echo '<script type="text/javascript" src="' . $template->get_template_dir('.js',DIR_WS_TEMPLATE, $current_page_base,'jscript') . '/file1.js"></script>'."\n";
    echo '<script type="text/javascript" src="' . $template->get_template_dir('.js',DIR_WS_TEMPLATE, $current_page_base,'jscript') . '/file2.js"></script>'."\n";
    echo '<script type="text/javascript" src="' . $template->get_template_dir('.js',DIR_WS_TEMPLATE, $current_page_base,'jscript') . '/file3.js"></script>'."\n";

    It looks to me like they are supposed to auto-load but nothing happens unless I hard code it. Existing code snip below:

    /**
    * load all site-wide jscript_*.js files from includes/templates/YOURTEMPLATE/jscript, alphabetically
    */
    $directory_array = $template->get_template_part($template->get_template_dir('.js',DIR_WS_TEMPLATE, $current_page_base,'jscript'), '/^jscript_/', '.js');
    while(list ($key, $value) = each($directory_array)) {
    echo '<script type="text/javascript" src="' . $template->get_template_dir('.js',DIR_WS_TEMPLATE, $current_page_base,'jscript') . '/' . $value . '"></script>'."\n";
    }

    /**
    * load all page-specific jscript_*.js files from includes/modules/pages/PAGENAME, alphabetically
    */
    $directory_array = $template->get_template_part($page_directory, '/^jscript_/', '.js');
    while(list ($key, $value) = each($directory_array)) {
    echo '<script type="text/javascript" src="' . $page_directory . '/' . $value . '"></script>' . "\n";
    }

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

    I have tried getting the script to load by adding the script files into:

    includes/modules/pages/index/

    but it doesn't work.


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

    So does anyone know where to put the script file so that ONLY a specific page within Zen Cart will load it? I have read several articles saying it can be done, but none of the instructions are right....

    Adrian

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

    Default Re: Javascript on Main Page

    load all site-wide jscript_*.js files

    You need to name the files according to the convention so they will be picked up.

    jscript_file1.js
    jscript_file2.js
    jscript_file3.js

    or something more descriptive.

  7. #7
    Join Date
    Sep 2007
    Posts
    47
    Plugin Contributions
    0

    Default Re: Javascript on Main Page

    Aha - I wasn't looking closely enough and assumed the the code was looking for a *.js file in a jscript directory [ ../jscript/myfilename.js] as this is the structure elsewhere in the code.

    Now that you have pointed this out I can see it is actually prefixing the variable value with [ jscript_ ]

    Thanks for that, that sorts a major roadblock I had! Adrian

  8. #8
    Join Date
    Sep 2007
    Posts
    47
    Plugin Contributions
    0

    Default Re: Javascript on Main Page

    LOL. FYI in the end I had to go back to hard-coded script file insertion. The reason being that the auto-loading of the jscript_*.js files seems to be based on the URL variable main_page=index (or other), so whilst it did work for the home page, as this variable is still used elsewhere in the site the scripts were being loaded on other pages as well, creating errors.

    Tried writing some conditional statements in the js code but it isn't simple nor obvious code, and js is certainly not my strong point so I gave up this line of attack....

    So I went back to hard-coding but added a php check for the cPath URL variable. As this URL variable *seems* (fingers crossed) to be used for deeper pages if it *doesn't* exist then I am assuming the user is at the home page and therefore the additional scripts are loaded and the slide-show runs.

    Hard-coding here not too naughty as it is in a template file anyway.

    Whole exercise not wasted time, as I need to load additional js files elsewhere in the site so now I know how to do this properly.

    Cheers, Adrian

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

    Default Re: Javascript on Main Page

    The $cPath test will only work for category/product pages. Any other kind of page will not have a cPath.
    The best test for homepage is a variable introduced in v1.3.7 called $this_is_home_page. It is always true on the homepage and false elsewhere.

  10. #10
    Join Date
    Sep 2007
    Posts
    47
    Plugin Contributions
    0

    Default Re: Javascript on Main Page

    sweet....this makes things foolproof.

    Because of the complex js I went and had a look-see at the sites that were first requesting this, and I see that they obviously gave up on this method and instead went to flash files!

    In my case I want to be able to reference specific files (eg. image1. image2, etc) so all the shop owner needs to do is upload new files named the same and they have a new slideshow.

    Cheers, Adrian

 

 
Page 1 of 2 12 LastLast

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. Feature products on category main page, but not on main home page
    By gems14k in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 17 Sep 2009, 03:47 PM
  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

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