Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Sub Category Images in 4.x Rate Topic   - - - - -

 
  • brandonvd
  • is Super Awesome
  • Members
  • Join Date: 19-Dec 06
  • 2633 posts

Posted 20 August 2013 - 08:27 AM #1

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

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1278 posts

Posted 20 August 2013 - 09:03 AM #2

Hi Brandon,

Follow steps:

1. you need to enable images again for categories in 4 they removed, they know the reason, please follow http://forum.cs-cart...en-removed-why/

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}<li><a href="{"categories.view?category_id=`$category.category_id`"|fn_url}">{$category.category}</a></li>{/if}
#with
{if $category}
    <li>
	    <a href="{"categories.view?category_id=`$category.category_id`"|fn_url}">
		    {include file="common/image.tpl" images=$category.main_pair image_width=100 image_height=100}
		    <span>{$category.category}</span>
	    </a>
    </li>
{/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
part of hungryweb.net

 
  • brandonvd
  • is Super Awesome
  • Members
  • Join Date: 19-Dec 06
  • 2633 posts

Posted 20 August 2013 - 09:32 AM #3

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}
                <li>
			        <div class="subcategory-images">
		            <a href="{"categories.view?category_id=`$category.category_id`"|fn_url}">
				        {include file="common/image.tpl" images=$category.main_pair image_width=$settings.Thumbnails.category_lists_thumbnail_width image_height=$settings.Thumbnails.category_lists_thumbnail_height}<br />
				        <span>{$category.category}</span>
		            </a>
				    </div>
                </li>
            {/if}

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

Brandon

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1278 posts

Posted 20 August 2013 - 09:53 AM #4

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

 

Posted 07 October 2013 - 10:33 AM #5

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

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1278 posts

Posted 08 October 2013 - 07:50 AM #6

Please PM me for help

 
  • brandonvd
  • is Super Awesome
  • Members
  • Join Date: 19-Dec 06
  • 2633 posts

Posted 10 October 2013 - 06:03 PM #7

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

Thanks,

Brandon

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1278 posts

Posted 14 October 2013 - 07:27 AM #8

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

 

Posted 15 October 2013 - 03:22 AM #9

Vali and brandonvd
Just a quick thanks for this code above - it was very helpful sorting out my category images. Fran
Regards Fran
You can find, follow, subscribe, connect, etc with my travels & family history or check out my daytime work. TravelGenee Online

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1278 posts

Posted 15 October 2013 - 06:17 AM #10

You are welcome.

 
  • dataspotgr
  • Advanced Member
  • Authorized Reseller
  • Join Date: 04-Sep 13
  • 67 posts

Posted 08 January 2014 - 08:17 AM #11

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

 
  • brandonvd
  • is Super Awesome
  • Members
  • Join Date: 19-Dec 06
  • 2633 posts

Posted 08 January 2014 - 11:57 PM #12

You need to do what is in http://forum.cs-cart...5965#entry15965

Thanks,

Brandon

 
  • robertparacay
  • Advanced Member
  • Members
  • Join Date: 14-Nov 11
  • 116 posts

Posted 09 January 2014 - 09:20 PM #13

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

 

Posted 27 January 2014 - 07:27 PM #14

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!

 

Posted 29 January 2014 - 06:37 PM #15

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!