Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Adding a <div> to a single category page

Adding a <div> to a single category page

Views: 870

Results 1 to 9 of 9
8 Jul 2013, 12:37 AM
#1
terrill_taylor avatar

terrill_taylor

New Zenner

Join Date:
Aug 2006
Posts:
96
Plugin Contributions:
0

Adding a <div> to a single category page

Hello -

So my site has a javascript slideshow that runs on the main page, and I would like to replicate that functionality on a product category page. It looks like if I put the script code into /templates/CUSTOM/jscript with a unique DIV ID then I can call the script in a blank <DIV> --- just not sure how to get the <DIV> into the category page...

8 Jul 2013, 2:23 AM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Adding a <div> to a single category page

A bit more detail on where you want to have this blank div located will help us advise. If the category description area will work, that is a no-brainer, just add the div to the description. If you want it elsewhere, it will be more complicated.

You do need a PHP test to make sure the script only tries to run for that particular category. A jscript_whatever.php file can hold that test, and only run the script in the right category.

8 Jul 2013, 11:57 AM
#3
terrill_taylor avatar

terrill_taylor

New Zenner

Join Date:
Aug 2006
Posts:
96
Plugin Contributions:
0

Re: Adding a <div> to a single category page

gjh42:

A bit more detail on where you want to have this blank div located will help us advise. If the category description area will work, that is a no-brainer, just add the div to the description. If you want it elsewhere, it will be more complicated.

You do need a PHP test to make sure the script only tries to run for that particular category. A jscript_whatever.php file can hold that test, and only run the script in the right category.

Thanks for the reply. So I do want the slideshow on a category description here. I put in the DIV with the same ID, like this ```html

<div id="fadeshow1"></div> ``` using the same ID from my main page, just to see if would load the same slideshow but it did not. I can see the DIV when I look at the page source, so I may be misunderstanding how it should work :dontgetit
8 Jul 2013, 12:10 PM
#4
terrill_taylor avatar

terrill_taylor

New Zenner

Join Date:
Aug 2006
Posts:
96
Plugin Contributions:
0

Re: Adding a <div> to a single category page

I just looked at the source for my main page, and the whole script is being loaded in the HEAD section. How do I get that to load in the HEAD section for a category? I think it's okay if that script is loaded on every category, so long as I only have a DIV in the description of the page where I want the slideshow...

8 Jul 2013, 5:50 PM
#5
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Adding a <div> to a single category page

Actually, it's the other way around. The empty div will silently sit there on any page without a script to use it, while the script without the div will give a fatal error.

You need a file like /includes/templates/your_template/jscript/jscript_cat_slideshow.php
with content like ```php

<?php if ($current_page_base == 'index' and $cPath == '23') { ?> <your script code> <?php } ?> ```
17 Aug 2013, 2:25 PM
#6
terrill_taylor avatar

terrill_taylor

New Zenner

Join Date:
Aug 2006
Posts:
96
Plugin Contributions:
0

Re: Adding a <div> to a single category page

I had given up on this, but I'm circling back to try again... so the script is loading from /includes/templates/<my temlate>/jscript and I can see it in the <head> section when I view the page source. I can also see the empty <div>, but still no slideshow :( any thoughts or ideas would be much appreciated.

18 Aug 2013, 2:52 AM
#7
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Adding a <div> to a single category page

There's nothing I can say without seeing your site live... aside from the obvious "you have some erroneous code somewhere"...

18 Aug 2013, 3:30 PM
#8
terrill_taylor avatar

terrill_taylor

New Zenner

Join Date:
Aug 2006
Posts:
96
Plugin Contributions:
0

Re: Adding a <div> to a single category page

gjh42:

There's nothing I can say without seeing your site live... aside from the obvious "you have some erroneous code somewhere"...

This is the category page where I want the slideshow:
http://www.banberryplace.com/index.php?main_page=index&cPath=67

If you view the source you can see 2 iterations of the Dynamic Drive script is being loaded from /includes/templates/ban/jscript - I have added the one with the wrapperID: fadeshow2 - at this point I'm just trying to replicate the slideshow on the main page, figuring that if I can at least get a slideshow to show up then I can change the images as needed...

20 Aug 2013, 8:42 AM
#9
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Adding a <div> to a single category page

We get this sort of thing to work by applying the jscript embedding principles applicable to zencart.

In general, a "sitewide" enablement of jscript can be achieved by putting the jscript.js file into modules/pages/index