Most Popular and Recently Added Products

Top  Previous  Next

The top products and latest additions may be displayed in shopping cart catalog and search pages by inserting PHP code in the page where it is to appear.

 

clip10125

The scripts that produce these lists may be included in...

page templates
any custom web page of your choice
the storefront index.php script or any other custom php script

 

There are two ways to include the lists, either through Javascript or a PHP include. This is how to use the Javascript version...

 

       <script language="JavaScript" src="top.js.php"></script>

 

And this is how to use the PHP include version...

 

       include "includes/toplist.inc.php";

 

Note that the second version only works in a PHP script.

 

Parameters may be added to both versions of the script to customize the output. To add a parameter to the Javascript version, first add a question mark "?" and then add the parameter. If more than one parameter is specified, add an ampersand "&" after the first parameter and to separate additional parameters. Here is an example.

 

       <script language="JavaScript" src="top.js.php?items=5&redirect=product.html"></script>

 

To add a parameter to the PHP include version, set it as a variable before the include statement. For example:

 

       $redirect="index.php";

       include "includes/toplist.inc.php";

 

Number of Products Shown

If not otherwise specified, the top.js.php script will display the last 10 new products and latest additions. To display a lower number of products,  add the parameter "items=x" where x is the number of products to display.

 

This include will display the 5 most popular and latest additions:

 

       <script language="JavaScript" src="top.js.php?items=5"></script>

 

Or for the PHP include version use:

 

       $items = 5;

       include "includes/toplist.inc.php";

 

Redirect To A Different Product Page

In shops where only custom catalog pages are used and a direct link to the default storefront script is not desired, the top.js.php product links can be redirected to the custom catalog pages by adding a "redirect=x" parameter, where x is the local file name or URL.

 

This include will display the 10 most popular and latest additions in a custom product page named "product.html".

 

       <script language="JavaScript" src="top.js.php?redirect=product.html"></script>

 

The Layout Parameter

By setting the layout parameter you can control which lists are shown. These are the possible values of the parameter:

 

layout = 0 : show top sellers and latest additions below top sellers (the default mode)
layout = 1 : show only top sellers
layout = 2 : show only latest additions
layout = 3 : show latest additions as boxes, this mode is currently only supported by the Javascript version

 

This example will show only the latest additions, using the PHP include, and will limit the list to 4 items:

 

       $layout = 2;

       $items = 4;

       include "includes/toplist.inc.php;

 

The Mode Parameter

By setting the mode parameter you can select if the top list should be formatted as a table or an unordered list. This is only available when using the php version. These are the possible values of the parameter:

 

mode = table : show top sellers and/or latest additions as a preformatted table (the default mode)
mode = list : show top sellers and/or latest additions as an unordered list for further formatting through CSS.

 

Table Header Text

The text that appears at the top of the listings is set in the corresponding language file, language/xx/topjs.inc.php, where xx is the language abbreviation. For example, the text for English language is set in language/en/topjs.inc.php.

 

Colors, and Fonts

The table borders, background colors, and fonts can be controlled through the Layout menu and with style sheets (CSS).