Jump to content

Latest Products to Categories


Recommended Posts

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


Link to comment
Share on other sites

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:


{if isset($LATEST_PRODUCTS)}


{if isset($TLC_ON_HP)}
    {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:"&hellip;"}</a></p>

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:

  // 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) {
      $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'], '&amp;');
      $tlc_on_hpData[] = $tlc_on_hpRecord;

  if (!empty($tlc_on_hpData)) {
    $GLOBALS['smarty']->assign('TLC_ON_HP', $tlc_on_hpData);





Assign images to your TLCs. Test again.

Link to comment
Share on other sites

  • 2 weeks later...

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!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...