Sub Category Images in 4.x

Has anyone done subcategory images in 4.x yet? I'm trying to figure it out, but I just can't quite get it. If anyone has figured it out and would like to share the code, that would be great.



Thanks,



Brandon

Hi Brandon,



Follow steps:


  1. you need to enable images again for categories in 4 they removed, they know the reason, please follow [url=“http://forum.cs-cart.com/tracker/issue-4332-image-categories-in-v401-has-been-removed-why/”]http://forum.cs-cart.com/tracker/issue-4332-image-categories-in-v401-has-been-removed-why/[/url]



    2.on file app/controllers/frontend/categories.php

    #replace
    Registry::get('view')->assign('subcategories', fn_get_subcategories($_REQUEST['category_id']));


    #with
    $data = array (
    'category_id' => $_REQUEST['category_id'],
    'visible' => true,
    'get_images' => true
    );
    list($subcategories, ) = fn_get_categories($data);
    Registry::get('view')->assign('subcategories', $subcategories );




    3.on file design/themes/basic/templates/views/categories/view.tpl

    #replace
    {if $category}
  2. {$category.category}
  3. {/if}


    #with```php

    {if $category}


  4. {include file="common/image.tpl" images=$category.main_pair image_width=100 image_height=100}
    {$category.category}


{/if}

```



PS: you can hook to categories:view but you need to override all content, to fn_get_subcategories you cannot hook, sow this are modifications to core



I hope that helps,





Valentin

[color=#808080][size=2]part of hungryweb.net[/size][/color]

Valentin,



Cool, that helped tons, thank you very much for posting that.



I did make some small changes to fit my needs though. The biggest was making is so the thumbnail sizes can be set in the admin. I just changed your code to:


{if $category}




  • {/if}




    Thank you again for your help, it is really appreciated.



    Brandon

    You’re welcome,

    Code has no copyright rules, you can change it as you wish :))) and any suggestion is welcomed and your is very user friendly

    I am at a loss, I have editted the orginal files that were commented out for Images on cat. and changed the coding you guys listed and still when i go to create a new Category theres nothing showing to add images nor showing anything in the thumbnail area to adjust the size, its like nothing was changed even though i have checked and triple checked all of the files. i have cleared cache on admin panel and even the browser. Any Idea?



    thanks,

    eric

    Please PM me for help

    You need to ftp in and clear the cache manually. I think it is var/cache. Just clear everything in there.



    Thanks,



    Brandon

    please try to clear cache this way [ [color=#ff0000]admin.php[/color]?cc&ctpl ] browser cache has no impart in regards to comment and uncomment tpl files or php code

    Vali and brandonvd

    Just a quick thanks for this code above - it was very helpful sorting out my category images. Fran

    You are welcome.

    This code works perfect. Thank you. I have a question: Where do we add the image for the subcategory?

    You need to do what is in http://forum.cs-cart.com/tracker/issue-4332-image-categories-in-v401-has-been-removed-why/page__gopid__15965#entry15965



    Thanks,



    Brandon

    Has anyone figured out how to properly align these category thumbnails? As it is, it's a mess

    Hey guys, I am running 4.0.3 and I followed all of the steps listed above. I am not able to see a blank thumbnail on category's, but I am unable to save an image for each category. I choose upload, select the image and click save and nothing changes. Any help would be great, thanks!

    Hey guys, I am running 4.0.3 and I followed all of the steps listed above. I am not able to see a blank thumbnail on category's, but I am unable to save an image for each category. I choose upload, select the image and click save and nothing changes. Any help would be great, thanks!