Archive for the ‘Smarty’ Category
Tuesday, January 25th, 2011
In smarty templates you can access Request variables available in PHP scripts using the reserved template variable {$smarty}. Request variables include $_GET, $_POST, $_SERVER, $_ENV, $_COOKIE and $_SESSION.
Posted in Others, Smarty | No Comments »
Sunday, January 23rd, 2011
Generally when majority of your templates use the same headers and footers, it is obviously a good choice to split those out into their own templates and include them. But what if the header needs to have a different title, depending on what page you are coming from? For this ...
Posted in Others, PHP, Smarty | No Comments »
Sunday, January 23rd, 2011
Sometimes instead of printing an empty variable you may need to print a default value. For example printing a sign "*" instead of printing nothing so that the page should appear in understandable form. Yes! you can use rather most of the people use {if} statement for this but there ...
Posted in Others, PHP, Smarty | No Comments »
Saturday, January 22nd, 2011
Displaying rows or tables of information in alternate background colors is a nice way to improve readability. You may have used alternate css style in template using {if} tag but there is a smarty tag {cycle} which you can use to set the alternating CSS styles.
Here is a sample code ...
Posted in Others, Smarty | No Comments »
Saturday, January 22nd, 2011
Using Smarty method get_template_vars(), you can access the smarty template variables in PHP scripts. However, these template variables are only available after or during the execution of template. The other way to use those template variables can be achieved by embedding PHP code directly into the smarty template using {php} ...
Posted in Others, PHP, Smarty | No Comments »
Saturday, January 22nd, 2011
{capture} tag is used to assign any output it generates, into a variable that you can use to display that captured content multiple times throughout your templates. For that you can assign the output to the variable :
[html]
{capture name='navbar'}
<ul>
{section name=item loop=$nav}
<li><a href="{$nav[item].urlid}">{$nav[item].title}</a></li>
{/section}
</ul>
{/capture}
[/html]
Posted in Others, Smarty | No Comments »