Ben224 Posted December 30, 2013 Share Posted December 30, 2013 Hello fellow Cubecarters. I am developing my second store now and would like to have a homepage that displays rows of images that represent my individual categories. So for instance instead of the standard Latest Product images on the home page that click through to products I would like the following: For category A: Big Red Apples An image of a big red apple on the home page which when clicked loads the category listing page for big red apples. For category B: Big Green Apples An image of a big green apple on the home page which when clicked loads the category listing page for big green apples and so forth. So essentially I want to represent an entire category with an image on the homepage and not an individual product as is standard with the Latest Products feature. Can anyone help? Categories can already be allocated an image can they not? Is there a way to shift this rationale to the home page? Thanks in advance Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 31, 2013 Share Posted December 31, 2013 The following will make the "top level categories" (TLC) be listed like the Latest Products cells. Please make this edit to the skin template file content.homepage.php: FIND: {if isset($LATEST_PRODUCTS)} ADD ABOVE: {if isset($TLC_ON_HP)} <h2>{$LANG.navigation.title}</h2> {foreach from=$TLC_ON_HP item=category} <div class="latest_product"> <p class="image"><a href="{$category.url}" title="{$category.cat_name}"><img src="{$category.image}" alt="{$category.cat_name}" /></a></p> <p class="title"><a href="{$category.url}" title="{$category.cat_name}">{$category.cat_name|truncate:38:"…"}</a></p> </div> {/foreach} {/if} In admin, Manage Hooks, Code Snippets tab, create a new snippet: Enabled: Green tick Unique ID: TLC_ON_HP@Ben224 Description: Replaces Latest Products with Top Level Categories on the HomePage Trigger: class.cubecart.display_homepage Version: 1.0.0 Author: BSmither on CubeCart Forums PHP Code: {php} // Using class.cubecart.display_homepage hook if (($tlc_on_hpResults = $GLOBALS['db']->select('CubeCart_category', false, array('cat_parent_id' => 0, 'status' => 1))) !== false) { foreach($tlc_on_hpResults as $tlc_on_hpRecord) { $GLOBALS['language']->translateCategory($tlc_on_hpRecord); $tlc_on_hpRecord['image'] = $GLOBALS['catalogue']->imagePath($tlc_on_hpRecord['cat_image'], 'small','url'); $tlc_on_hpRecord['url'] = $GLOBALS['seo']->buildURL('cat', $tlc_on_hpRecord['cat_id'], '&'); $tlc_on_hpData[] = $tlc_on_hpRecord; } } if (!empty($tlc_on_hpData)) { $GLOBALS['smarty']->clearAssign('LATEST_PRODUCTS'); $GLOBALS['smarty']->assign('TLC_ON_HP', $tlc_on_hpData); } {/php} Save. Test. Assign images to your TLCs. Test again. Quote Link to comment Share on other sites More sharing options...
Ben224 Posted January 13, 2014 Author Share Posted January 13, 2014 Hello bsmither, Apologies for the delayed response, I haven't had the opportunity to implement this until today. Thank you so much for putting this code snippet together! It has been a complete success and exactly what I was looking for. Very very pleased indeed. This makes the program so much more powerful and future versions would benefit from an option like this becoming available as standard in my opinion. Many thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.