TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   about smarty (http://www.talkphp.com/absolute-beginners/1975-about-smarty.html)

webtuto 01-16-2008 02:24 PM

about smarty
 
hi
i was trying with smarty i saw 2 tutorials but i didnt get the main idea
i know its to separate coding from html but i dont know how to do that i saw these tutorials but no result
is there anyone here have some time that can help me out in msn messenger or skype ...

RobertK 01-16-2008 02:48 PM

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.

webtuto 01-16-2008 03:26 PM

thanks for the forum :d
anyway i know these things but what i dont get is for exemple
when the user login to the website i want the welcom message to be in the middle of the page not on the top :s
i want to control the results of my queries in the design

RobertK 01-16-2008 04:38 PM

Yes, this is what Smarty does. You write the templates for the pages, and it outputs exactly what you want, how you want it. So if you want it in the center, write it so the template has the text centered; the output HTML will have it centered too.

webtuto 01-16-2008 05:11 PM

thanks dude im gonan try to learn about smarty


All times are GMT. The time now is 07:40 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0