Separate Designers & Coders With Smarty Templates
May 3rd, 2006 by admin
Many times the case seems to be that a person who can code great scripts can rarely do great design. This is why many large sites have programmers AND designers. A problem can arise with this arrangement when customizing the look of the application. Generally the designer doesn’t have the first clue about PHP and very bad things can happen.
Wouldn’t it be nice if the output could somehow be separated from the code so coders and designers don’t have to clash?
Well there is a way, and it is called The Smarty Template Engine. What is the Smarty Template Engine? The technical definition of a template engine is code that facilitates a manageable way to separate application logic and content from its presentation. Basically, your script provides all the information to the engine, and Smarty uses it, along with a template file to display it with standard HTML tags.  There are many built in Smarty tags that allow you to perform many functions found in PHP if necessary. You can even add your own functions to Smarty!
Smarty allows you to separate code from layout. You do not need to add anything special to your PHP installation, and can include all the Smarty files with your application. Just require smarty in your scripts and you can use the code to handle all of your output. It even facilitates output buffering with filters.
One large benefit to using Smarty is caching. Smarty can cache pages or even just parts of pages to drastically increase load times, especially on pages where content doesn’t change frequently.
You can find more on Smarty at the PHP web site here: http://smarty.php.net.
This entry was posted on Wednesday, May 3rd, 2006 at 9:59 pm and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.