-
Notifications
You must be signed in to change notification settings - Fork 0
LiteCommerce module: custom html block in the sidebar
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:
-
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>
-
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'; } }
-
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.