Sub Category Images (complete solution)

Sweet mod - nice work DarinnEagle & welcome aboard!

welcome everyone…i tried hard to get it to work

[quote name=‘darinneagle’]set your cs-cart to have the images on the filesystem and there you go, no_image still works and you get the exact thumbnail for every category that has one…working demo on [url]林芝诓勺餐饮管理有限公司

nice looking site there so you into cycles i see well as you can tell what my line of work is by my screenname anyhow just thought i say looks ok i but needs a little work done to it

calvin

yep needs some work here and there…but overall it makes money…i work on it in my freetime

This MOD is AWESOME !!!



Many thanks!

Francesco

[quote name=‘baballuci’]



$cat_var = fn_get_category_imagepath($smarty_var);

[/QUOTE]



I changed images to the File System and overwrote the categories.tpl file with the code posted. The above line is giving me an error when I check the site from the front end.



It says “fn_get_category_imagepath” is undefined.



:confused:



—> I just noticed the code for the above function…gonna see if it works…

—> nevermind guys!!! it works!! thanks for posting on here!!!

Any idea if this works with 1.3.5? I guess I could test it, however seeing as it will be tonight before I can do that, I’d ask.



Thanks,

JB

I can’t believe this isn’t standard! It’s what I need. :smiley:



However, does it work on 1.3.5 and will it work considering I have images in a file system?



All the efforts here are very much appreciated.

[quote name=‘baballuci’]Thanks DarinnEagle, this works great. It should be there as standard.



For those who cannot get this to work, make sure you select an image to use for the subcategory,


  1. Goto Manage Categories
  2. Choose the sub category
  3. Choose the ICON image.
  4. Save changes.



    This is my Categories.tpl (complete)

```php

{* $Id: categories.tpl 2153 2006-10-03 06:07:12Z zeke $ *}



{capture name=“mainbox”}



{if $subcategories or $category_data.description}

{$category_data.description}





{*
*}

{foreach from=$subcategories item="category"}
{if $category}

{else}

{/if}
{/foreach}

{/foreach}



{include file="common_templates/image.tpl" show_detailed='Y' images=$category_data.main_pair object_type="category" no_ids=true}

{split data=$subcategories size=$columns|default:"3" assign="splitted_categories"}
{math equation="floor(100/x)" x=$columns|default:"3" assign="cell_width"}

{foreach from=$splitted_categories item="subcategories"}


{assign var=darin value=$category.category_id}
{php}
$smarty_var = $this->get_template_vars('darin');
$cat_var = fn_get_category_imagepath($smarty_var);
$this->assign('category_image', $cat_var);
{/php}
{$category.category}


{if $category_image == "no_image.gif"}
{$category.category}
{else}
{$category.category}
{/if}





{/if}

{if $products}
{if $settings.Appearance.columns_in_products_list > 1}
{include file="products_pages/products_multicolumns.tpl" columns=$settings.Appearance.columns_in_products_list}
{elseif $settings.Appearance.advanced_products_list == 'Y' && $client_env.is_javascript == 'Y'}
{include file="products_pages/products_advanced.tpl" title=""}
{else}
{include file="products_pages/products.tpl" title=""}
{/if}

{elseif !$subcategories}

{$lang.text_no_products}


{/if}

{/capture}
{include file="common_templates/mainbox.tpl" title=$category_data.category content=$smarty.capture.mainbox}

{if $featured_products}
{include file="addons/featured_products/customer_categories.tpl"}
{/if}

{if $settings.Modules.discussion == 'Y'}
{include file="addons/discussion/discussion.tpl" object_id=$category_data.category_id object_type="C" title=$lang.discussion_title_category}
{/if}
```

I've commented out the "standard category image" at the top of the page and added ' style="border: none" ' to the images so as not to get a blue/purple hyperlink boarder.[/QUOTE]

This in the caregories.tpl coupled with darinneagle's work makes this mod work a treat :D Well done guys. baballuci...thanks for also getting rid of the parent category image too...it makes so much more sense now.

Result! All I need to do is add some breaks between the titles and tweak it but wow...nice stuff indeed guys.

Oh...I'm using 1.3.5! Get it in 1.3.6 ;)

Spoke a little too soon. It takes the sub-category’s image away from it’s own section! :confused:



But it’s fixed my IE6 issue/bug with descriptions not showing…even more :confused:

I’ve solved it in a way that the sub category icon/image shows in each final section also but the main category icon/image doesn’t show in the nice list of thumbs neatly laid out thumbs.



Granted it may not be great use of the code (an if/else statement would be much better) but I simply added:


{include file="common_templates/image.tpl" show_detailed='Y' images=$category_data.main_pair object_type="category" no_ids=true}



In the 2 places in the product chunk of code at the end of categories.tpl so that if that section has or hasn’t got products the section icon still shows with the description at the top.



I’m using brands as sections so it’s good to keep this in for me :slight_smile:


```php {if $products}

[COLOR=“Red”]{include file=“common_templates/image.tpl” show_detailed=‘Y’ images=$category_data.main_pair object_type=“category” no_ids=true}[/COLOR]

{if $settings.Appearance.columns_in_products_list > 1}

{include file=“products_pages/products_multicolumns.tpl” columns=$settings.Appearance.columns_in_products_list}

{elseif $settings.Appearance.advanced_products_list == ‘Y’ && $client_env.is_javascript == ‘Y’}

{include file=“products_pages/products_advanced.tpl” title=“”}

{else}

{include file=“products_pages/products.tpl” title=“”}

{/if}



{elseif !$subcategories}

[COLOR=“Red”]{include file=“common_templates/image.tpl” show_detailed=‘Y’ images=$category_data.main_pair object_type=“category” no_ids=true}[/COLOR]

{$lang.text_no_products}


{/if} ```

It works so I guess it'll do ;)

I also removed the text from the thumb list so it now looks nice and neat.

If anyone can suggest and if/else if statement to clean it up I'd appreciate it :)

How would i go about making these so the list horizontal instead of vertical which they do at the moment?

Nevermind, found the css for the subcategories.



just changed it from:



.subcategories {
font-size: 11px;
font-weight: bold;
line-height: 17px;
display: table;
}




to:

.subcategories {
float: left;
font-size: 11px;
font-weight: bold;
margin: 0px 15px 15px 0px;
line-height: 17px;
display: inline;
}

I was having problems with this mod with no images either…

for this to work you have to set your images under “file” not “database” under settings>general>images






[quote name=‘tonybeam’]I have added these changes, it works . . . kind of. It shows an image box for each subcategory, and the links work, but it’s not pulling my images for some reason.



I have attempted to modify the code with no success. Here are my changes:

{$category.category}


{if $category_image == "no_image.gif"}
{$category.category}
{else}
{$category.category}
{/if}





Anyone have any ideas?



Also . . . where would I specify a class to this code? I want to modify the defualt font and image border.[/QUOTE]

Wow, dude. Thanks for going to the trouble to write these mods. My category pages look much better now (see artevida.com – or if this post is stale, I might have moved it to its permanent location - www.artevida.com).



My website is all about seeing product, product, product… and I don’t want it to look all amateur web store-ish, so this mod has really helped me get there.



P.S. - Of course I didn’t have time to make my website this fancy. I hired some web designers from India to do it, and they did a great job.:eek:



Brent

pretty neat to see my idea is still working great almost a year later :stuck_out_tongue:

Thanks for sharing this great piece of code!



However, I still have issues implementing this. The PHP function always returns with no_image.gif. I was trying to debug the function and I saw that image_path in cscart_category_images is empty. Even if I try to replace the image_id with one entry that does contain something in the image_path filed, it still doesn’t work (cannot find image on the server).



Any ideas what happens or if there has been any changes done to CS Cart that disable this?



I’m using the latest version of CS Cart.



Many thanks in advance for your time and help!

OK! I found out what went wrong :slight_smile: I had to change the image storage to be File System rather than Database. For this go to the admin panel, select Settings (right side menu) and change the ‘Images location’ option to File System. Finish it up by pressing the Update button at the bottom.

Brilliant work nice to see this has been put into the updated verion(s) of cs-cart too ! I was wondering though could something like this be adopted to display the category images in the left category side block ? Basically id like to display the categories image to the left of the category name in the side block. So far ive had little luck, there should be a variable in place already but i havent found one as of yet. Looks like im going to have to hard code it to get what i want :(.

[quote name=‘darinneagle’]next you want to edit your “categories.tpl” file



completely remove the entire {foreach}{/foreach} and all the lines inbetween it



then you want to paste this over




{foreach from=$subcategories item=category}
{assign var=darin value=$category.category_id}
{php}
$smarty_var = $this->get_template_vars('darin');
$cat_var = fn_get_category_imagepath($smarty_var);
$this->assign('category_image', $cat_var);
{/php}

{$category.category}
{if $category_image == "no_image.gif"}
{$category.category}
{else}
{$category.category}
{/if}


{/foreach}






of course you might want to edit that to your liking, but its the basics that will get you going[/QUOTE]



where is this categories.php file please?