m_torrance Posted January 27, 2013 Share Posted January 27, 2013 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> <h1>{$product.name}</h1> </div> {/foreach} and here is a link to the page. http://www.cookiedoodleshop.com/shop/index.php Thanks a bunch, Mark Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 27, 2013 Share Posted January 27, 2013 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> Quote Link to comment Share on other sites More sharing options...
m_torrance Posted January 27, 2013 Author Share Posted January 27, 2013 Thanks for the quick response! Worked like a charm! Just curious. If a product has more then one image is there a way to link to a specific one? Thanks Again, Mark Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 27, 2013 Share Posted January 27, 2013 Oh, yeah! That made a big difference! I don't think so -- other than making sure the image you really, really want is identified as the Main Image on the admin Edit Product screens. Quote Link to comment Share on other sites More sharing options...
m_torrance Posted January 27, 2013 Author Share Posted January 27, 2013 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? Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 27, 2013 Share Posted January 27, 2013 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 Quote Link to comment Share on other sites More sharing options...
m_torrance Posted January 27, 2013 Author Share Posted January 27, 2013 Perfect! Thanks so much! Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 27, 2013 Share Posted January 27, 2013 Yeah! I like how that turned out! Quote Link to comment Share on other sites More sharing options...
m_torrance Posted January 28, 2013 Author Share Posted January 28, 2013 Thanks! 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? Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 28, 2013 Share Posted January 28, 2013 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. 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.