phpfluxlib template engine

phpfluxlib template engine :: Documentation


The phpfluxlib template engine consists of several logically separated elements, glued together using a simple centralized XML configuration file (or several). It is based in the Tiles library, a plugin for Jakarta Struts.

Templates are an agregation of layouts and blocks that are called programaticly to present a page. A template can inherit data (blocks and the layout) from another template, hierarquicly.

Layouts are a simple php script that define the structure of the layout, placing the blocks inside the design. They can define static named blocks, like 'header' and 'footer', or more dynamic, for example, receiving a list of blocks and iterating them in a column fashion, implementing a dinamic columned layout.

Blocks provide the website content. They can be any file that can be included through 'include()' or values like:

  • static HTML
  • PHP scripts
  • Strings
  • Another template (providing greater abstraction possibilities)
Blocks can receive data programaticly, before calling the layout, and provide reusability through abstraction.


Properties are defined in the configuration XML file and provide global configuration variables throughout the website and also inside the XML config file.


<template name="baseLayout" layout="${LayoutDir}/siteLayout.tpl.php">
	<block name="title" type="string" value="${TituloSite}" />
	<block name="header" type="page" value="${BlocksDir}/common/header.php" />
	<block name="footer" type="page" value="${BlocksDir}/common/footer.php" />
	<block name="GoogleAnalyticsTracker" type="page" value="${BlocksDir}/googleAnalytics.php" />
	<block name="menu" type="template" value="" />


	<meta http-equiv="Content-Type" content="text/html; charset=<?= $tpl->getProperty('GlobalCharset');?>">
	<title><? $tpl->putBlock('title');?></title>
	<link rel="stylesheet" href="css/style.css">
<body >
	<table cellspacing="0" cellpading="0" class="main center" align="center">
			<td class="header"><? $tpl->putBlock('header');?></td>
			<td class=""><? $tpl->putBlock("menu"); ?></td>
			<td class="title"><? $tpl->putBlock('title');?></td>
			<td class="content"><? $tpl->putBlock('content');?></td>
			<td class="footer"><? $tpl->putBlock('footer');?></td>
	<? $tpl->putBlock('GoogleAnalyticsTracker');?>


<script src="" type="text/javascript">
<script type="text/javascript">
_uacct = "<?= $tpl->getProperty('GoogleAnalytics_uacct');?>"