DescriptionPlugin to allow the use of phptal templates
Ownerdaryn@iivip.com
Last changeFri, 9 Apr 2010 21:16:44 +0000
Mirror URLgit://git.mantisforge.org/phptal.git
http://git.mantisforge.org/r/phptal.git
Push URLssh://git.mantisforge.org/srv/git/phptal.git
Content tags:
Add:
readme

Configuring another plugin to use phptal

Use full page layout template

To use the default plugin templates for displaying the mantis phptal layout the plugin includes a template_api file which replaces the html apis. This is a temporary solution and is not complete but it does allow most pages to be output in the current mantis style quite simply. For the standard html_page_* functions simply replace 'html_' with 'template_'. The output is removed and the variables are returned in an array to be assigned to the template.

This is the quick and dirty code to add to the pages in order to get the variables needed in the default templates:

$t_phptal->index_page = true; # robot index

# call any template_* functions you need to use and assign the values to an array
$t_tplvars = array();
$t_tplvars += template_page_top1( plugin_lang_get( 'title' ) );
$t_tplvars += template_page_top2();
$t_tplvars += template_page_bottom();

# loop through and assign the vars to the template
foreach( $t_tplvars AS $t_var=>$t_val ) {
    $t_phptal->$t_var = $t_val;
}

Use the default templates, wrap your template files as follows:

<html metal:use-macro="default/layout.html/layout">
<style metal:fill-slot="styles">
    #### YOUR CUSTOM PAGE STYLES HERE ####
</style>
<script metal:fill-slot="scripts" type="text/javascript">
    #### YOUR CUSTOM PAGE SCRIPT HERE ####
</script>
<div metal:fill-slot="content">
    ### YOUR TEMPLATE CONTENT GOES HERE ###
</div>
</html>

*** NOTE: You should use the resources event for including javascript and css files. The script and style sections above are for page specific js/css

Use standard Mantis html_api for layout

If you do not want to use the PHPTal templates for the mantis layout you may call mantis html header/footer functions before and after executing the phptal template as shown below.

html_page_top1( plugin_lang_get( 'title' ) );
html_page_top2();

# execute the template
try {
     echo $t_phptal->execute();
}
catch (Exception $e){
     echo $e;
}

html_page_bottom1( __FILE__ );

No layout template for processing event signal fragments

If you are outputting page fragments rather than full pages simply execute the template as shown below without either the html_* or template_* functions. This is usually done in a plugin event callback function.

function report_bug_form() {
     $t_phptal = PHPTalPlugin::load();
     $t_phptal->setTemplateRepository( config_get_global( 'plugin_path' ) . 'PLUGIN_NAME/templates' );

     $t_phptal->customers = PMCustomer::load_all();
     $t_phptal->releases = PMRelease::load_all( array($this->foundin_release_id));
     $t_phptal->setTemplate( 'bug/report.xhtml' );
     $t_phptal->setPostFilter(NULL);

# execute the template
     try {
          echo $t_phptal->execute();
     }
     catch (Exception $e){
         echo $e;
     }
}
If you've configured the plugin to use the Tidy Filter you may disable tidy for an individual template before executing the template for that page.
$t_phptal->setPostFilter(NULL);
shortlog
2010-04-09 Daryn Warriner main menu needed for layout and login page needed for... master
2010-04-09 Daryn Warriner Simplify use so inheritance is not needed. Add configu...
2010-04-09 Daryn Warriner Simplify use so inheritance is not needed. Add configu...
2009-11-25 Daryn Warriner Add a note regarding disabling Tidy filter
2009-11-25 Daryn Warriner Update phptal library to version 1.2.1
2009-11-25 Daryn Warriner Fix plugin version to reflect version of phptal used...
2009-10-29 Daryn Warriner missing colon
2009-10-28 Daryn Warriner Add template_api to replace calls to html_api. Add...
2009-09-28 Daryn Warriner Initial commit creating MantisBT plugin to hook PHPTal...
heads
2 years ago master