How to Add a New Sidebox to Zen Cart

A Zen Cart sidebox is what displays various items in the side columns of your Zen Cart store. By default numerous sideboxes will show in either the left or right column of a Zen Cart online store for instance the categories sidebox, the search sidebox, and the information sidebox. Adding a new sidebox to Zen Cart can be completed in a few quick steps. You will need access to the server to add and modify files.

Add a Zen Cart Sidebox:

  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.

That is all that needs to be completed for the sidebox to show on your site. The book below is a great reference for modifying or adding items to your Zen Cart store.

Share