NewsFeaturesDownloadsDevelopmentSupportAbout Us
Plugin templatefilter

Plugin templatefilter

From LifeType Wiki


Name: templatefilter

Latest version: 1.0

Download link: http://prdownloads.sourceforge.net/lifetype/1.1_templatefilter.zip?download

License: GPL

Author: Pan Ying (panying2000@gmail.com)

[edit] Description

This plugin provide a global method to insert code in every template before they are rendered.

This would make it possible to for example inser the 'authimage' code to all templates that need it at run time, dynamically, without the need to ask users to make the modifications to templates on their own.

[edit] Configuration

1. Copy the plugin file in the zip file to <lifetype>/plugins/templatefilter\


2. Insert these lines inside <lifetype>\class\template\template.class.php after line 95:

include_once( PLOG_CLASS_PATH."plugins/templatefilter/plugintemplatefilter.class.php" );

Smarty::register_postfilter('PluginTemplateFilterSmartyPostFilter');

Smarty::register_prefilter('PluginTemplateFilterSmartyPreFilter');

[edit] Notes

This version provides 2 examples, which should have real function:

1. The ability to add Google Analytics code before </body> Post template compiled. You should change the plugin code to add your own Google Analytics code.

2. The ability to add AuthImage code before </form> Before template compiled. The function only work in "commentform.template", and will first try to check AuthImage code exist or not.

It is recommended to take a look at the plugin code in order to understand the features provided.

[edit] More examples

Insert the bad-behaviour plugin code dynamically:

            $arrayPluginTemplateFilterSmartyPreFilter[] = Array(
              "pattern" => "/\$badbehavior/i",
              "replace" => "",
              "templatename" => "header.template",
              "group" => 6,
              "onlymatch" => true,
              "disabled" => false
            );

//insert before </head>
            $arrayPluginTemplateFilterSmartyPreFilter[] = Array(
              "pattern" => "/<\/head>/i",
              "replace" => "    {if !empty(\$badbehavior)}
      {\$badbehavior->showBB2JavaScript()}
    {/if}
       </head>",
              "templatename" => "header.template",
              "group" => 6 ,
              "onlymatch" => false,
              "disabled" => false
            );