RSS

How to Add a Sidebox to Zen Cart

Sat, Nov 14, 2009

Zencart

A Zen Cart sidebox is what displays various items in the side columns of your Zen Cart store.There are already so many sideboxes in zencart, like category, like user reviews, like search, but sometimes we need more functions to customize, so we have to add the new sidebox to zencart.

but as you konw, zen cart is php developed, it’s not easy to find the way to add it in the control panel for a zen cart new learner as me, so I prepare you a tutorial way to add a new sidebox, here you go.

1, Create Sidebox Template:Add a new file to the server in the following directory: zen-cart-root/includes/templates/template-name/sideboxes/. You should name the file something relating to the contents of the sidebox. In this example we will be adding a welcome message sidebox so we might name the file tpl_welcome.php. The contents of the file will include what you want to display in the box and will be in a $content variable. Below is an example of the contents of the file if you wanted it to just display a message like “Welcome to my store”.

<?php
/**
* Side Box Template
*
*/
$content = 'Welcome to my store.';
?>

2,Create Sidebox:Now we want to add the actual sidebox which goes into the following directory: /zen-cart-root/includes/modules/sideboxes. Again name the file something relating to the contents of the sidebox which in this case will be welcome.php. The contents of this file will look something like the below so just modify the variables that relate to your template.

<?php
/**
* welcome sidebox - used to display a welcome message in a sidebox
*
*/// test if box should display
$show_welcome = true;if ($show_welcome == true) {require($template->get_template_dir(‘tpl_welcome.php’,DIR_WS_TEMPLATE, $current_page_base,’sideboxes’). ‘/tpl_welcome.php’);
$title = BOX_HEADING_WELCOME;
$title_link = false;
require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,‘common’) . ‘/’ . $column_box_default);
}
?>

3, Add Language Variables:You now need to modify the english.php language file to add the definitions for any text variables you have used in either file. In this example we have added a new variable called BOX_HEADING_WELCOME. So for this example you would add the below to english.php.

// welcome box text in sideboxes/welcome.php
define(‘BOX_HEADING_WELCOME’, ‘Welcome Message’);

Note above that BOX_HEADING_WELCOME is the name of the variable used and “Welcome Message” is the text that is displayed anywhere that the variable is used.

4, Enable Sidebox:Now visit the Zen Cart admin system in your browser to turn the sidebox on. Once you have logged into the admin hover over Tools and select “Layout Boxes Controller” from the drop down. You will see the new sidebox in the list which in this example is sideboxes/welcome.php. Click on the new box twice and in the upper right of the window you will see fields that  you can edit. Type the correct number is the sort order field to display the box, select the radio button next to on in “Left/Right Column Status”, and then click the Update button. Your new sidebox is now enabled on your site.

5, Verify Sidebox:Now visit your Zen Cart store in a browser and the sidebox should show.

Incoming search terms for the article:

Related Posts

,

This post was written by:

Kent - who has written 274 posts on Kent’s Blog.

Working in the English Search Engine industry, focusing on the new media and new economy, Trying to find out a way for e-commerce integration!

Contact the author

2 Comments For This Post

  1. Breadfan Says:

    Great read! thx

  2. loop Says:

    I have been searching for sites related to this. Glad I found you. Thanks

Leave a Reply

Powered by Yahoo! Answers