Thread: about smarty
View Single Post
Old 01-16-2008, 02:48 PM   #2 (permalink)
RobertK
The Addict
Top Contributor Good Samaritan 
 
Join Date: Jan 2008
Location: USA
Posts: 217
Thanks: 16
RobertK is on a distinguished road
Default

What don't you get about the main idea? The main idea of a template engine is to let you abstract, make variable or immaterial (not concrete), your interface to files that can be edited apart from your source. What you do in your script for a page is gather your data, then assign it to Smarty:
PHP Code:
$smarty = new Smarty();

$smarty->assign('firstname''Doug');
$smarty->assign('lastname''Evans');
$smarty->assign('meetingPlace''New York');

$smarty->display('index.tpl'); 
If your template looks like the following, the output after it will be seen.
smarty Code:
Hello {$firstname} {$lastname}, glad to see you can make it.
<br />
{* this will not work as $variables are case sensitive *}
This weeks meeting is in {$meetingplace}.
{* this will work *}
This weeks meeting is in {$meetingPlace}.
Becomes:
HTML Code:
Hello Doug Evans, glad to see you can make it.
<br />
This weeks meeting is in .
This weeks meeting is in New York.
This is to separate your data from the display, so that your interface and code are more flexible. The template doesn't care who gave it the data, just that it is there. And your script doesn't really care where the data came from, so long as it fits your requirements and rules (for security mostly).

If you can describe your confusion better, perhaps I can helpyou. Otherwise, I do know that Smarty has a support forum in French, if you know it better than English.
__________________
Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning. - Rich Cook
RobertK is offline  
Reply With Quote