bestseller side-box hack

I made a hack for version 1.3.4 (maybe also work in v.1.3.3)

so that the bestseller-side-box can be set to 3 different modes:

1: default (standard CS-cart)

2: vertical scrolling with productimages and pause on onmouseover

3: product after product in a box with productimages (time-interval)

They all have some easy-2-set variables in the top of the file for

the display_type, height, image-width and divider color.

Its an easy hack: 2 actions:



[COLOR=“red”]A NEW FILE, SO NO WORRIES AT ALL :slight_smile:

Copy all the text below and save in a NEW file in the directory:



* Smarty plugin
* @package Smarty
* @subpackage plugins

* Smarty {getimageid} function plugin
* Type: function

* Name: getimageid

* Purpose: returns image_id from given product_id
* @author nwsco
* @param array
* @param Smarty
function smarty_function_getimageid($params, &$smarty)

global $db_tables;

if (!isset($params['var'])) {
$smarty->trigger_error("getimageid: missing 'product_id' parameter");

if($params['var'] == '') {

//get imageid from product_id, store in var:

$tmp_id = db_get_row("SELECT * FROM $db_tables[product_images_links] WHERE product_id = " . $params['var']);
$_result = $tmp_id;

if (!empty($params['assign'])) {
$smarty->assign($params['assign'], $_result);
} else {
return $_result;




[COLOR="Red"][B]STEP 2[/B][/COLOR]
[COLOR="red"]Replace ALL the code in the file
with the code below, or change if newer/older version then 1.3.4:[/COLOR]```php
{* $Id: sidebox.tpl 2126 2006-09-19 13:57:58Z zeke $ *}
{if $bestsellers}

{assign var="display_type" value=3} {*1,=standard cs-cart, 2=browsercompatible scroll with pause on onmouseover, 3=changing blocks*}
{assign var="sidebox_height" value="100"} {*height in pixels*}
{assign var="thumb_width" value=40} {*width of thumbnail*}
{assign var="divider_color" value="#cccccc"} {*color of the divider (only display_type 1)*}
{* END EDIT *}


{if $settings.General.images_location == "database"}
{assign var="tmp_object_type" value="product"}
{else} {* image is stored in file system *}
{assign var="tmp_object_type" value="common"}

{capture name="sidebox"}

{if $display_type eq 1}

{foreach from=$bestsellers item=bestseller}



{elseif $display_type eq 2}


position: relative;
width: 100%;
height: {/literal}{$sidebox_height}{literal}px;
overflow: hidden;


{foreach from=$bestsellers item=product}


{getimageid var=$product.product_id assign="tmp_images"}
{include file="common_templates/image.tpl" image_width=$thumb_width obj_id=$product.product_id images=$tmp_images object_type="$tmp_object_type"}



{assign var="cnt_b" value=1}
{foreach from=$bestsellers item=product}

{assign var="cnt_b" value=$cnt_b+1}

{getimageid var=$product.product_id assign="tmp_images"}
{include file="common_templates/image.tpl" image_width=$thumb_width obj_id=$product.product_id images=$tmp_images object_type="$tmp_object_type"}




{include file="common_templates/sidebox.tpl" title=$lang.bestsellers content=$smarty.capture.sidebox icon="sidebox_icon_bestsellers.gif"}

An example of display_type 2 and 3 (1=cs-cart default: paste the default
code in there if your version is newer)

This is just a q&d hack, adjust to your needs when a little goes wrong or so.
it shouldnt tho, since one file is new, and the other is easily replaced!
(or set display_type to 1, which is cs-cart default v.1.3.4)

Or download as easy zip, read the readme.txt, which is included.....

Tested in ie6,ie7 & FF1.07


Hi nwsco

Looks like another nice little mod, i love little mod that enhance the overall look of the cart, will try it late M8.


Hi nwsco

The mod works well if images are in DB, but if images are in File system no images show.

Thanks nwsco

To get the images to show when images are in the file system go to…/bestsellers/sidebox.tpl and find in two places

{include file="common_templates/image.tpl" image_width=$thumb_width obj_id=$product.product_id images=$tmp_images object_type="product"}

and change the object_type to “common” so your new line of code looks like:

{include file="common_templates/image.tpl" image_width=$thumb_width obj_id=$product.product_id images=$tmp_images object_type="common"}

thx for that sno!

i changed that in the code above, so it is automatically changed now,

depending on the db-storage-system used…

Hi nwsco

I have tried the new changes in the code, but it still want show images in file system.

hi john.

i just presumed sno’s solution would work, since i dont use the filesystem.

so you say it doesnt, anything wrong sno?

can this be done for the cart sidebox? so thumbs appear?



of course mirkury, but wouldnt that make the cart-sidebox a bit too busy?


I tried this on 1.3.3 and although the text scrolls fine, there is no image.

I tried the fix and it didn’t work either.

All my pictures were uploaded via the admin product pages to the DB. Any ideas??



hey scott,

sorry, i dont have 1.3.3 here installed. it probably works (quite)

different, so thats why the images dont show…maybe someone else?

1.3.4 is coming out any day now b.t.w…

No worries… I just turned off “bestsellers” until 1.3.4 comes out. I will try the mod again then.


After I changes as u said, no images displayed, just display this error:

[QUOTE]Warning: Smarty error: unable to read resource: “common_templates/image.tpl” in /data/htdocs/classes/templater/Smarty.class.php on line 1096[/QUOTE]

The same problem for “Newest Products”. My cs-cart version is 1.3.3.

cs-cart technician reply as below:

[QUOTE]There is no such “image.tpl” file in the “skins/[CUSTOMER_SKIN]/customer/common_templates/” directory by default in CS-Cart.

The template for displaying product images - “product_image.tpl” is located in the “skins/[CUSTOMER_SKIN]/customer/products_pages” directory of your CS-Cart location. And template for displaying category images - “category_image.tpl” is located in the “skins/[CUSTOMER_SKIN]/customer/categories_pages” directory of your CS-Cart location.[/QUOTE]

The scroll effection is activated.

Anyone can help me?

btw, All product pictures are stored in File System.


I tried this on 1.3.3 and although the text scrolls fine, there is no image.



After I changes as u said, no images displayed… My cs-cart version is 1.3.3.


The code above will not work properly on 1.3.3 setups because the image display functions have changed in version 1.3.4. You can do a quick fix for 1.3.3 setups if you have the images in the database, but if images are in the file-system, unfortunately, several code changes would need to be made. I have not had the opportunity to thoroughly review the code above, so I cannot tell you what those changes are at the moment.

For the quick fix for 1.3.3 with images in the database, in the sidebox.tpl file, you can change the 2 lines that start with:

{include file=“common_templates/image.tpl” …

with the following code:


{include file=“products_pages/product_image.tpl” image_width=$thumb_width}


compernicus, thank u all the same.

Hope someone else can help me to solve this. Thanks.

I want to return back, but since I delete the “fuction.getimageid.php”, it will display this error:[QUOTE]Fatal error: Smarty error: [in addons/bestsellers/sidebox.tpl line 101]: [plugin] unknown tag - ‘getimageid’ (core.load_plugins.php, line 118) in /data/htdocs/classes/templater/Smarty.class.php on line 1096[/QUOTE]

Very strange, looking someone can help me to resolve this problem, thanks.

ok, I figured this out by myself just now.go to CSCARTROOT/skins//customer/addons/bestsellers, change two places in sidbox.tpl. There are two place shows:“common_templates/image.tpl”

use “products_pages/product_image.tpl” to instead.

Then, it is working perfectly.

oh… It just like compernicus said!

But really, figured out by myself. YEAH!

hi nwsco

it took me a while to re read this post sorry for the delay.

i am stripping this cart down so for the purposed i am going to use this for it will suit in a really nice way. =)

“of course mirkury, but wouldnt that make the cart-sidebox a bit too busy?”

oops sorry… i was thinking that once there was an item purchased and the item went into the cart side box, thumbnails would show up instead of a text list of what the customer is buying.