Tutorials/Customize OXID eShop With oxBlocks

One of the important new features in OXID eShop 4.5.0 is the addition of oxblocks in the new 'azure' theme. These are predefined blocks that can be overwritten by any module. The block definitions in the templates (and their usage in modules) are Smarty3-syntax compatible.

= Block Usage =

In templates, the blocks are defined by

tags, and can by used in overridden blocks with the [{$smarty.block.parent}] tag.

Here is an example:

This block can be activated by inserting the following SQL statement to the OXID eShop database (only necessary in OXID eShop version < 4.6.0):

An overridden module block has to be defined in a separate template file placed in the following module path:

See screencast below for an working example.

Note: any change regarding blocks requires eShop/tmp/ cache to be re-populated.

=Block Debugging= To see all defined blocks while browsing the OXID eShop, you can activate

in the config.inc.php. This will enable the debug layer in the frontend, displaying the position and place of all rendered blocks per page.

=Admin Blocks=

Since OXID eShop 4.6.0, admin templates also support blocks. This makes it possible to enable the following features:


 * Append forms with needed input fields:


 * Include new CSS files:


 * Include new JavaScript files:


 * Append JavaScript:

=Default oxBlocks=

=Important Notes=


 * Language files from eshop/modules/&lt;module&gt;/out/lang/&lt;current lang&gt;/*_lang.php will be loaded automatically.


 * The oxViewConfig object has several convenience methods for interacting with module blocks:
 * return path to the requested module file:
 * return url to the requested module file:


 * It is always a good idea to provide a .htaccess file in the module directory which allows the module CSS, JS and image files to be loaded while disallowing access to the PHP and other files, as these should not be available to users.

=Resources=

Screencasts
You can use the following screencast to find out more about the new template inheritance feature. This feature optimizes the template handling system, making it easy to create flexible designs and integrate templates. The screencast was recorded by Sarunas.

Note: Since the screencast was created, the module blocks path has been changed to eshop/modules/&lt;module&gt;/out/blocks/&lt;blockname&gt;.tpl

Sourcecode used in this screencast
modules/partnerlogo/out/blocks/mypartner.tpl: 

modules/partnerlogo/out/blocks/redborder.tpl: 

Data in oxtplblocks:

(Note: In Oxid eShop 4.5.6 the path of partners.tpl changed slightly compared with the screencast example).