Skip to content

LiteCommerce module: custom html block in the sidebar

beatnbite edited this page Feb 3, 2012 · 2 revisions

In the stand-alone version of LiteCommerce there is no function to add and manage sidebar blocks with custom HTML code. To do it you should create a custom module as follows:

  1. Create a blank LiteCommerce module.

  2. Now lets add a custom HTML block to the sidebar. Create the "classes/skins/default/en/modules/<your developer ID>/<your module ID>/myblock.tpl" file and edit it as follows (to show the block lower in the sidebar, specify a higher value for the "weight" attribute):

     {*
      * @ListChild (list="sidebar.first", zone="customer", weight="40")
      *}
     <div id="my-custom-block">
         <p>This is a test block</p>
     </div>
    
  3. Now a more complex example that displays your HTML code inside the default block wrapper. Create the "skins/default/en/modules/<your developer ID>/<your module ID>/my_widget/body.tpl" file and put there your block contents. Then create the "classes/XLite/Module/<your developer ID>/<your module ID>/View/MyWidget.php" file and edit it as follows:

     <?php
     
     namespace XLite\Module\<your developer ID>\<your module ID>\View;
     
     /**
      * @ListChild (list="sidebar.first", zone="customer", weight="45")
      */
     class MyWidget extends \XLite\View\SideBarBox
     {
     
         /**
          * Return the block title
          *
          * @return string
          */
         protected function getHead()
         {
             return 'My Custom Widget';
         }
     
     
         /**
          * Return the path to the directory with the widget template file
          *
          * @return string
          */
         protected function getDir()
         {
             return 'modules/<your developer ID>/<your module ID>/my_widget';
         }
     
     }
    
  4. Re-build the LiteCommerce classes cache (the shop back-end -> "Maintenance" tab -> "Re-Build cache" page) to get the new module listed among other modules on the "Add-ons" page. Enable the module (this will re-build the cache once again) and see your blocks in the sidebar.

Clone this wiki locally