Smarty Template: Basics That You Must Know


Smarty Template Step By Step Tutorial - Part 4: All command at Smarty is in delimeter {}. Now, we will see something basic at Smarty. You must know about them.

Comment

Comment is statements that added at code to explain any or to give note. In Smarty we can use such as:

<Body>
{* this template use Smarty! *}
{* put any code at here! *}
</Body>

Method

Such as other classes, Smarty have methods. We can use smarty method to help our job. I just want to show a little and we will talk later.

<Body>
{config_load file="colors.conf"}
{include file="header.tpl"}
{if $somebody}
 Wellcome, {$name}
{else}
 Who are you?!?
{/if}
</Body>

Attribute

Such as HTML, in Smarty tag/command can have attribute. Example:

<Body>
{include file="footer.tpl"}
</Body>

Variable

<Body>
{func var="test $foo test"}
{func var="test $foo_bar test"}
{func var="test $foo[0] test"}
{func var="test $foo[bar] test"}
{func var="test $foo.bar test"}
{func var="test `$foo.bar` test"}
</Body>

Mathematic

<Body>
{$foo * $bar}
{$foo + $bar}
</Body>



Bookmark and Share Tag: smarty, template, command Category: PHP Classes Post : May 02nd 2008 Read: 69,345

advertisements


blog comments powered by Disqus