Skip to content

Documentation for PHP developers

rainphp edited this page Dec 27, 2014 · 6 revisions

RainTPL 2 require PHP > 5 to run. The easiest way to install it and learn how it works is by checking the example in the main folder.

Install RainTPL

  1. Download the main Rain TPL script
  2. Copy it in your library folder for example in inc/rain.tpl.class.php.
  3. Now create an index.php file:
    <?php
    require "inc/rain.tpl.class.php";
  1. Configure Rain TPL:
    $config = array(
                     "tpl_dir"       => "tpl/test/",
                     "cache_dir"     => "cache/"
    );
    raintpl::configure( $config );
  1. Init, assign and draw the template:
    $tpl = new RainTpl;
    $tpl->assign('title','Hello!');
    $tpl->draw('test');

Configurations

You can change the default configuration using the raintpl::configuration method, here's the list of the possible configurations:

  • tpl_dir, is the template directory, eg:
raintpl::configure('tpl_dir', 'templates/'); 
  • cache_dir, where it save compiled templates and cache, eg:
raintpl::configure('cache_dir', 'cache/'); 
  • base_url, the absolute base url of your application, eg:
raintpl::configure('base_url', 'http://www.raintpl.com'); 
  • tpl_ext, the extension of your templates, eg:
raintpl::configure('tpl_ext', 'html'); 
  • path_replace, enable/disable the path replace, true or false are possible values, eg:
raintpl::configure('path_replace', false); 
  • path_replace_list, configure what to replace, list an array with the values, eg:
raintpl::configure('path_replace_list', array( 'img', 'link', 'script' )); 
  • black_list, configure what command are not allowed, eg:
raintpl::configure( 'black_list', array('_SESSION') );

Clone this wiki locally