phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Smarty Template: Basics That You Must Know

Tag: smarty, template, command   Category: PHP Classes
post: 02 May 2008 read: 307


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>



| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting