Here is a  list of tips and tricks you can use during developing/integrating HostBill templates.

Controlling Smarty library behaviour through config.php file


HostBill configuration file (includes/config.php) allows to override some Smarty library settings, without the need to modify underlying library code. Following settings can be overrided:

  1. Security settings → PHP_TAGS (ref: https://www.smarty.net/docsv2/en/variable.security.settings.tpl )
    To enable use of Smarty {php} tags, add following to bottom of includes/config.php file:

    $config['Smarty.PHP_TAGS']=true;



  2. Trusted directories - to be used with {include_php} tag - (ref: https://www.smarty.net/docsv2/en/variable.trusted.dir.tpl )
    To provide array containing list of trusted directories, add  to bottom includes/config.php file:

    $config['Smarty.trusted_dir']=[
     '/path/to/first/trusted/directory/',
     '/path/to/another/trusted/directory/'
    ];


  3. PHP handling - how Smarty should react php code (within <?php ?> tags) - (ref: https://www.smarty.net/docsv2/en/variable.php.handling.tpl )
    Set value below in includes/config.php:

    $config['Smarty.php_handling']=3;


    Following values are available:

Template cache


Sometimes your changes are not displayed immediately after modifying tpl file. To make it work you can:

Enabling PHP tags in smarty templates


{PHP} smarty tags are disabled for security purposes from smarty library. You can enable them at your own risk by editing Smarty library:

 /includes/libs/smarty/Smarty.class.php

change:

  line 231: 'PHP_HANDLING' => false,

to:

 line 231: 'PHP_HANDLING' => true,

change:

 line 238: 'PHP_TAGS' => false,

to:

 line 238: 'PHP_TAGS' => true,

change:

line 202: var $php_handling  =  SMARTY_PHP_PASSTHRU;

to:

line 202: var $php_handling = SMARTY_PHP_ALLOW;

Make sure not to overwrite your changes with upgrade.

Main Template file


Template file rendered when HostBill index.php is called without params is

 root.tpl

Located in your template directory.

Previewing new template


If you're working on new template in separate directory under /templates [ex. /templates/myintegration/ ]dir you don't need to change your current template just to preview your changes. You can add &systemtemplate=myintegration param to url just to change current template for your session. Note: You need to be logged in as administrator to do this.

Debugging template


When you've made mistake in Smarty syntax you wont be able to see your template (it will render blank) - you can enable error reporting in /includes/config.php file of your HostBill to locate where error has been made.

Getting full list of available variables in template


In order to do so you need to enable Smarty debugging in /includes/libs/smarty/Smarty.class.php (its not encrypted). Edit line 103: Code:

var $debugging  =  true;

Now with each page accessed smarty will pop-up debug console with list of all variables.

Including javascript code


If you wish to enter javascript code in your template files you need to enter them in {literal}{/literal} block - more info here: Link