Oke guys as promised I have reviewed my orginal implementation and made an extensive amount of changes to the site template handling. What has been changed :
1. patTemplate is no longer used to render the site templates.
This creates a nice speed increase of about 0.050 msec on my machine on a page load of +/- 0.4 sec. This means a 1/8 speed improvement.
2. and have been replaced by countModules function
This change creates alot more flexibility. The countModules function can be giving a condition made up out of module positions. For example :
- countModules('user1 and user2'), will return 1 if there are module(s) in user1 and user2 position
- countModules('user1 or user2'), will return1 if there are module(s) in user1 or user2 position
- countModules('user1 + user2'), will return the total amount of modules in user1 and user2 position
I believe this function will cover all your needs to create flexible templates that adpat themselves to published modules.
3. The template paremeters can be accessed using a bit of simple php code.
params->get('showComponent')) : ?>
4. Variables accessible through the template
$this->language, the language tag
$this->direction, the language direction
$this->template, the template name
$option, $mainframe, $Itemid are also accessible if needed.
5. How does the system render a site template ?
Site templates are rendered in two stages,
- first all PHP functions are executed and all variables are replaced by their values
- secondly the system searches for all the jdoc::include statements and replaces them with the output of the modules, component,...
I think these changes bring back the needed flexibility and as a bonus we get a decent speed increase. Power to the designers
Have a look at the changes made and let me know your thoughts. In the coming weeks I will be doing a series of blog posts to outline all the changes in the template system.