| Description | Plugin to allow the use of phptal templates |
| Owner | daryn@iivip.com |
| Last change | Fri, 9 Apr 2010 21:16:44 +0000 |
| Mirror URL | git://git.mantisforge.org/phptal.git |
| http://git.mantisforge.org/r/phptal.git | |
| Push URL | ssh://git.mantisforge.org/srv/git/phptal.git |
| Content tags: |
$t_phptal = PHPTalPlugin::load();
$t_phptal->setTemplateRepository( config_get_global( 'plugin_path' ) . 'PLUGIN_NAME/templates' );
$t_phptal->setTemplate( 'workorder/edit.xhtml' );
$t_phptal->customer_list = PMCustomer::load_all();
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;
}
<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
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__ );
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() {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 = 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;
}
}
$t_phptal->setPostFilter(NULL);
| 2 years ago | master | shortlog | log | tree |