Sub cat icon images anyone know how?

Is there any way when i view a MAIN cat that has a bunch of sub cats to have the image i select for each subcat to display int he main cat to represent that subcat

for example

MAINCAT>Imagefor cat 1 - image for cat 2 - image for cat 3

all displayed when the user clicks into that main cat… instead of seeing just a text link to click on for the subcats they see the images you select for those subcats?

bumpto that

No CS-Cart gurus know the answer to this? I’ve been wondering myself…


Cant happen without editing PHP files.

{$categories_data} ncludes information for icons as seen from debugger below

[COLOR=blue]{$category_data}[/COLOR][COLOR=green][B]Array (17)[/B]
[B]category_id[/B] => 152
[B]parent_id[/B] => 93
[B]id_path[/B] => 93/152
[B]owner_id[/B] => 0
[B]membership_id[/B] => 0
[B]avail[/B] => Y
[B]product_count[/B] => 7
[B]position[/B] => 10
[B]timestamp[/B] => 1129645895
[B]lang_code[/B] => EN
[B]category[/B] => Children's Books
[B]description[/B] => [I]empty[/I]
[B]meta_keywords[/B] => [I]empty[/I]
[B]meta_description[/B] => [I]empty[/I]
[B]main_pair[/B] => [B]Array (5)[/B]
[B]pair_id[/B] => 152
[B]image_id[/B] => 0
[B]detailed_id[/B] => 0
[B]type[/B] => M
[B]position[/B] => 0
[B]discount[/B] => 2.00
[B]discount_type[/B] => P[/COLOR]

{$subcategories} does not as seen below

[COLOR=blue]{$subcategories}[/COLOR][COLOR=green][B]Array (2)[/B]
[B]0[/B] => [B]Array (6)[/B]
[B]category_id[/B] => 152
[B]parent_id[/B] => 93
[B]id_path[/B] => 93/152
[B]category[/B] => Children's Books
[B]position[/B] => 10
[B]level[/B] => 1
[B]1[/B] => [B]Array (6)[/B]
[B]category_id[/B] => 153
[B]parent_id[/B] => 93
[B]id_path[/B] => 93/153
[B]category[/B] => Computers & Internet
[B]position[/B] => 20
[B]level[/B] => 1[/COLOR]

as you can see its missing data and this data is required when passing info off to /category_pages/category_images.tpl

So without CS making this a change across the board, its a customization.

appreciate the feedback man

There is an work around for this, seems to work quite well.

You need to create an image with each category id

i.e cat_1.gif cat_2.gif

Then in categories.tpl hard code an image in such as below, using the category_id to choose which image to load.

The downfall is, if you create a new category or an image doesnt exist you get the nasty old X in a box.


{foreach from=$scats item=“category”}

{if $category}





IGNORE IMAGES, IGNORE CONTENT... far from completed this store !


Sample only !

Just to add an update for those with 1.3.4 R3…

I used the method SWS posted but adjusted it for several things. I moved the category title code as I wanted to have the image clickable without any text, but I also needed to make sure and include the category title as alt/title text for the image. Not that for this version of CSC cat images are titled “category_image_[insert id number]”.


{foreach from=$subcategories item=category}



The only problem you might run into is that if you want an underline for standard hyperlinks this will show up under the image unless you change that, or create special link parameters for the 'subcategories' class.

I found a much better way to get images to show up for subcategories. Instead of hard coding the images in and having to manually upload your images, you can use the following piece of code so the category images you assign in the CS-Cart backend will show up. Just go into the categories.tpl file and inside the {foreach} loop place this line:


Hope this helps =)

UPDATE I played around with this more and it only works if you’re using the database to store images (on by default), does not work with file system.

Hey Suclonix…what version of CSC are you using? I tried your code but all I got was the “no image available” image. I do have cat images assigned but for some reason it’s not finding them.

I’m using 1.3.4 SP3. In order for this code to work you must go to settings, image location and make sure its set to database instead of file system.

Admittedly Ive not played with this for a while, since I only required it for a few categories… however should be really easy to make it work from filesystem too.

personally I think images in dbase is a bad idea as it adds extra overhead to the loading of the cart, but Its great to see somebody made a “real” fix for my hash up…

I will be reworking this myself soon also, so will post the code unless somebody beats me to it :wink:

any such luck? i dont store my images in the database and id love to use this feature without having to hard code anything and manually name each image…

Hmm, I don’t think its possible to call those images through the smarty templating system. You’d prally have to do it through the PHP files but I don’t really know–just my guess.

i assume that since it can be done via database…theres no reason it cant be done via local image files also…surely there is a way to do it…

Anythings possible, It wont take much to do it properly, as I say, I intend too just been a little busy lately.

My first hack at it was in the very first days of owning CS to get me live, Ive now modded quite a lot and used to the way CS is working

ive modded a TON of stuff on mine…but there has to be a way to do this…

ok by today ill have a fix for this once and for all…i got it to work flawlessly and ill post how to do it, however im trying to find a way to just intergrate it seemless into cscart without any problems or much modifying…just bare with me and ill get this done for everyone by the end of today

all someone has todo is tell me how to pass a variable from smarto to {php} and its done…

Does this help?


no, unfortunately it doesnt…i need it to be the other way around…

here is the code im using

$smarty_var = $this->get_template_vars('category.category_id');
$thetmp = fn_get_category_imagepath($smarty_var);
$this->assign('category_image', $thetmp);