Re: Template system in PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nathan Rixham wrote:
> Shawn McKenzie wrote:
>> Ryan A wrote:
>>> Add my vote too for Smarty....
>>> HTH,
>>> -R
>>>
>>>
>>>
>>>      
>>> ____________________________________________________________________________________
>>>
>>> Looking for last minute shopping deals?  Find them fast with Yahoo!
>>> Search. 
>>> http://tools.search.yahoo.com/newsearch/category.php?category=shopping
>>
>> I like smarty and it's very powerful, however what you find is that it's
>> just a less capable replacement for PHP.  If I want conditional
>> statements to display HTML and/or loop through arrays, why would I want
>> to do it in smarty tags?  Instead of moving display away from logic, it
>> just replaces the logic with a different language.  When I use templates
>> I pretty much want variable substitution.  My next project I'll probably
>> use HTML files with little bits of PHP echos etc... sprinkled throughout.
>>
>> -Shawn
> 
> re: If I want conditional statements to display HTML and/or loop through
> arrays, why would I want to do it in smarty tags?
> 
> Things are very different when there are a team of varyingly skilled
> people on the job, do you really want a junior designer going in and
> changing bits of a php application, when you could limit the damage to a
>  smarty template?
> 
> further; the font end smarty language is definately needed; concider
> 
> {if $articles}
> {*loop through articles and show in table *}
> {else}
> {* show no articles message *}
> {/if}
> 
> in my opinion, being able to dump that kind of ultra simple logic onto
> the designers makes:
> 1: my life much easier
> 2: my php files much neater
> 3: my code my "own domain" without worrying about random comments and
> breakages from designers
> 4: the designers happier as they have more freedom and power to control
> the display, without having to worry
> 
> final note:
> personally I output every script to a suitably named .tpl file with a
> single line {debug} - job done

I understand, but my point that I didn't make earlier is that I know PHP
so I use that.  Designers that I work with don't know PHP and don't know
smarty and have no desire to know.  They know graphic design and HTML.
So I would rather give them some meaningful tags to insert somewhere in
their HTML.  Actually moving the logic out of the presentation/design.

So instead of article.tpl:
{if $articles}
{*loop through articles and show in table *}
{else}
{* show no articles message *}
{/if}

I prefer to do this in my article.php:
if($articles) {
	include('article.html');
//or optionally file_get_contents() and do replace on tags
}else{
	return;
}

And let the designer have his article.html:
<table>
	<tr>
		<td><?php echo $something; ?></td>
<!-- or {something} that is replaced with echo $something; -->
	</tr>
</table>

-Shawn

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux