Jump to content

Links to product images for slider


Recommended Posts

Hi All,


I have placed a slider on the homepage of a site I'm setting up. I'm using Latest Products as a starting point and everything works fine except using {$product.image} of course gives the same size image that is used in the Featured Products box in the sidebar. How can I call a larger version of the image from the for loop?


Here is the foreach loop


{foreach from=$LATEST_PRODUCTS item=product}
<div class="peKb_active" data-delay="5" >
<a class="image" href="{$product.url}"><img src="{$product.image}" alt="{$product.name}" /></a>
and here is a link to the page.
Thanks a bunch,
Link to comment
Share on other sites

Welcome m_torrance! Glad to see you made it to the forums.


In the file cubecart.class.php, at about line 106 (depends what version of CC5 you are running), in the displayHomePage function, find:

$product['image'] = $GLOBALS['gui']->getProductImage($product['product_id'], 'small');

Add this line on a new line below it:

$product['image_large'] = $GLOBALS['gui']->getProductImage($product['product_id'], 'large');

Substitute large for any of:


thumbnail gallery normal enlarge tiny small medium large


The images in the Latest Products box are requested as 'small'.


Then, for the loop:

<a class="image" href="{$product.url}"><img src="{$product.image_large}" alt="{$product.name}" /></a>
Link to comment
Share on other sites

Well, that should be sufficient.


I would like to do a similar thing on the category pages. A slider at the top that populates with the image for the category then the products listed on that page. I have it working to the extent that the category images shows, but it is of course calling the thumbnail for the products. Where would I add the same or similar line of code to call the other sizes? In the cubecart.class.php file but somewhere outside of featured products?

Link to comment
Share on other sites

Luckily, for the View Category page, CubeCart gives us all the variables you need. So, in the template file content.category.php, in the code where you are adding the banner-slider, when iterating through $PRODUCTS, your {placeholder} will be {$product.size} where size is any of:

thumbnail subcategory gallery normal tiny small medium large

Link to comment
Share on other sites


Do you know if there is a way to get an array of the featured items?

It looks like the code in box.featured.php is getting a single random item from products that have "featured" turned on.

This would allow for the featured products to always populate the homepage slider so the items can be changed easily for different holidays etc.

Actually, I don't see a "featured" setting in products. HOw are the featured items determined?

Link to comment
Share on other sites

Actually, there is no "Display in Featured" store setting. (Although, over at www.cubecartforums.org, I recall seeing a mod to do that.) An item is chosen at random.


There have been several conversations that discuss how to fetch records that satisfy particular needs.

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...