ADDON: Subcategory Thumbnails

Those who want to have the same functionality but don’t want to use addon and hooks, here is the easy but a little hands on version:



In core fn.catalog.php find function: fn_get_categories

Add this before last line of the funtion where last “return” is:

```php foreach ($tmp as &$t){

$t[‘main_pair’]=fn_get_image_pairs($t[‘category_id’],‘category’,‘M’);

} ```



Then go to view.tpl in your skin and {$subcategories|@print_r}

You will see that you got new sub-arrays with links url and image src.



Mod to your pleasure…



PS: Have not tried with categories without icons, might need to if src==“” => custom pic.



Also, if you have category list on the left where customers select categories, now you can show icons there as well… if you want. Same array available there…

[quote name=‘TexasGuy’]Those who want to have the same functionality but don’t want to use addon and hooks, here is the easy but a little hands on version[/QUOTE]

Of course, you will then need reapply this change every time you upgrade since fn.catalog.php has changes in every release (at least, this has been the case historically).



Bob

I don’t mind. This way if something does not work, I would be able to arrive at the solution faster. But, again, this is just me.

Thanks for the info. I can use it on my site! :wink:

[quote name=‘TexasGuy’]Those who want to have the same functionality but don’t want to use addon and hooks, here is the easy but a little hands on version:



In core fn.catalog.php find function: fn_get_categories

Add this before last line of the funtion where last “return” is:

```php foreach ($tmp as &$t){

$t[‘main_pair’]=fn_get_image_pairs($t[‘category_id’],‘category’,‘M’);

} ```Then go to view.tpl in your skin and {$subcategories|@print_r}

You will see that you got new sub-arrays with links url and image src.



Mod to your pleasure…



PS: Have not tried with categories without icons, might need to if src==“” => custom pic.



Also, if you have category list on the left where customers select categories, now you can show icons there as well… if you want. Same array available there…[/quote]



I almost appreciate your modification, but who did you post this for?



“Then go to view.tpl in your skin and {$subcategories|@print_r}

You will see that you got new sub-arrays with links url and image src.”



Where and what is this? There are about 13 “view.tpl” in the /skins folder.

Okay I gave up trying to figure out Texasguys cryptic code and worse yet baballuci’s original mod no longer seems to work with CS 2.014 - breaks the sub category pages so they no longer show any product information. I’m thinking it’s a conflict with the products list options.



Has anyone had success getting this to work in the latest CS version?

[quote name=‘Dave the Slave’]Okay I gave up trying to figure out Texasguys cryptic code and worse yet baballuci’s original mod no longer seems to work with CS 2.014 - breaks the sub category pages so they no longer show any product information. I’m thinking it’s a conflict with the products list options.



Has anyone had success getting this to work in the latest CS version?[/quote]



I’m gonna fire ma lazors this week to get something that works myself. :slight_smile:

Can’t wait Scotty!

Jesse any progress getting this working with 2.0.14?

[quote name=‘Dave the Slave’]Jesse any progress getting this working with 2.0.14?[/quote]



Not so far no, just upgraded a test store to attempt it.

Okay thanks. We really need to get this new version live so I also submitted a ticket - to me there seems to be something broken. After months of using 2.0.4 with this great modification I just now thought, why did a CS customer need to modify the core code when there is a feature in the back-end to upload images for categories/sub-categories just as with products, and category images appear but sub-category images do not; they appear only as hyperlinks?



So we have staff uploading all these great category images only so they appear as hyperlinks!

Okay got a response from Mikhail who directed me to a KB article - who knew!



[url]CS-Cart Documentation — CS-Cart 4.15.x documentation



While it works, it only works partially because the sub-category pages show no products, no images, no data, nothing. Submitted a follow-up ticket just now so hopefully this gets corrected so we can move on.

sub-category-page.png

main-category-page.png

I tried uploading a gif animation as a thumbnail but it didn’t work. Is it possible to do this?

This addon is being tried on this site but 2 products added in this category aren’t appearing, however these products can be viewed without this addon. Any suggestion?



pls visit: flexi labels . co .uk … all one word and click address labels and then 1 label per sheet sub-category



please advise immediately. thanks!

anybody please as this is an urgent task???

[quote name=‘Dave the Slave’]Okay got a response from Mikhail who directed me to a KB article - who knew!



[url]CS-Cart Documentation — CS-Cart 4.15.x documentation



While it works, it only works partially because the sub-category pages show no products, no images, no data, nothing. Submitted a follow-up ticket just now so hopefully this gets corrected so we can move on.[/QUOTE]



I can’t seem to access the link Mikhail shared with you, Dave.



Any luck implementing this with the most recent version of CS-Cart?

I apologize for not updating my posts - Mikhail had to admit the KB is seriously flawed and provided me with the ‘correct’ method for v2.1.4:



In “view.override.tpl” file, located in the “skins/[CUSTOMER_ACTIVE_SKIN]/customer/addons/my_changes/hooks/categories” directory



REPLACE:


{if $subcategories or $category_data.description || $category_data.main_pair}
{split data=$subcategories size=$columns|default:"COLUMN_NUMBER" assign="splitted_subcategories"}
{math equation="floor(100/x)" x=$columns|default:"COLUMN_NUMBER" assign="cell_width"}
{if $category_data.description && $category_data.description != ""}

{$category_data.description|unescape}

{/if}

{foreach from=$splitted_subcategories item="scats"}

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

{else}

{/if}
{/foreach}


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

{else}

{/if}
{/foreach}

{/foreach}

{include file="common_templates/image.tpl" show_detailed_link=false object_type="category" images=$category.main_pair no_ids=true class="cm-thumbnails"}




{/if}
{if $smarty.request.advanced_filter}
{include file="views/products/components/product_filters_advanced_form.tpl" separate_form=true}
{/if}
{if $products}
{if $settings.Appearance.columns_in_products_list > 1}
{include file="views/products/components/products_multicolumns.tpl" columns=$settings.Appearance.columns_in_products_list}
{else}
{include file="views/products/components/products.tpl" title=""}
{/if}
{elseif !$subcategories}

{$lang.text_no_products}


{/if}
{capture name="mainbox_title"}{$category_data.category}{/capture}




WITH:


{if $subcategories or $category_data.description || $category_data.main_pair}
{split data=$subcategories size=$columns|default:"COLUMN_NUMBER" assign="splitted_subcategories"}
{math equation="floor(100/x)" x=$columns|default:"COLUMN_NUMBER" assign="cell_width"}
{if $category_data.description && $category_data.description != ""}

{$category_data.description|unescape}

{/if}
{if $category_data.main_pair}

{include file="common_templates/image.tpl" show_detailed_link=true images=$category_data.main_pair object_type="category" no_ids=true class="cm-thumbnails"}


{if $category_data.main_pair.detailed_id}
{include file="common_templates/previewer.tpl"}
{/if}

{/if}

{foreach from=$splitted_subcategories item="scats"}

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

{else}

{/if}
{/foreach}


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

{else}

{/if}
{/foreach}

{/foreach}

{include file="common_templates/image.tpl" show_detailed_link=false object_type="category" images=$category.main_pair no_ids=true class="cm-thumbnails"}




{/if}
{if $smarty.request.advanced_filter}
{include file="views/products/components/product_filters_advanced_form.tpl" separate_form=true}
{/if}
{if $products}
{assign var="layouts" value=""|fn_get_products_views:false:0}
{if $category_data.product_columns}
{assign var="product_columns" value=$category_data.product_columns}
{else}
{assign var="product_columns" value=$settings.Appearance.columns_in_products_list}
{/if}

{if $layouts.$selected_layout.template}
{include file="`$layouts.$selected_layout.template`" columns=`$product_columns`}
{/if}

{elseif !$subcategories}

{$lang.text_no_products}


{/if}
{capture name="mainbox_title"}{$category_data.category}{/capture}

Thanks. I will try to implement that change shortly.



I noticed that the my_changes directory is not listed when accessing /skins/basic/customer/addons/



Any suggestion there?



I see the addon listed in Administration > Add Ons through the control panel. Very odd.

Is the My Changes addon installed and enabled?

Yes, apparently it is.