Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

templates?

0 views
Skip to first unread message

WebRod

unread,
May 30, 2005, 9:08:53 AM5/30/05
to
Hi,

i want to rewrite my website to separate the php script from the HTML code.
Therefore a web designer can update the design of the website without any
knowledge in PHP.

I read a lot of information about several templates like PhpLib,
FastTemplates, Smarty etc etc.

Some do not have a specific language so you cannot do complex things.
For example it's not easy to display a table (sometimes you need to have a
specific template to display the TR HTML tags...).
, it's not easy to use a different color to display a table row according to
a parameter etc etc

Some have a specific language, like Smarty.

My question is, what is the interest to learn another language??
What is the real interest of Smarty (or other one)?

What is the difference between these 2 situations:
I explain to a webdesigner this code:
{section name=sec1 loop=$contacts}
phone: {$contacts[sec1].phone}<br>
fax: {$contacts[sec1].fax}<br>
cell: {$contacts[sec1].cell}<br>
{/section}

Or I explain this:
foreach($contacts as $key=>$contact){
phone: <? echo $contact["phone"]?><br>
fax: <? echo $contact["fax"]?> <br>
cell: <? echo $contact["cell"]?> <br>
}

So I really think it's better to have;
- a php script which set some variables
- a HTML templates which build the content of the page. It uses a lot of
HTML tags and of course some really basic php function (if, foreach, echo).

Of course the php script call the HTML template.
You only use php, you work with the same variables, you don't need to call
some specific functions (assign etc etc), you don't need to know another
language etc etc.

Am I wrong??

Is there any interest to use Smarty (or other one)??
Why do they exist??????
And maybe why do YOU use them????

Manys thanks

Rod


Mick Sharpe

unread,
May 30, 2005, 9:43:25 AM5/30/05
to
I use Template_IT since it allows me to have no PHP code in my HTML files
and no HTML in my PHP scripts. Templates don't always make it easy to
achieve this, but they do make it possible.


Mike Willbanks

unread,
May 30, 2005, 10:52:09 AM5/30/05
to
> Some do not have a specific language so you cannot do complex things.
> For example it's not easy to display a table (sometimes you need to have a
> specific template to display the TR HTML tags...).
> , it's not easy to use a different color to display a table row according to
> a parameter etc etc
>
> Some have a specific language, like Smarty.
>
> My question is, what is the interest to learn another language??
> What is the real interest of Smarty (or other one)?

For me I have always considered this a loss. Why add another language
ontop of PHP? To me I think it is easier to have PHP just render
everything instead of having to learn more templating languages.

The only thing I use templates for currently is a custom made XML based
system. Takes the sections of an XML document combines them and then
parses using PHP.

All variables are exported to that template so then you have a set of
like 5 variables for that page. So therefore all the main logic is
contained in its pure PHP form and then the templates are seperated but
the variables remain the same.

Ex:
each page calls index.php which checks account validity, session, and
template file to include. Runs through the build process if there isn't
one in the cache or if there is an updated file.

now the file is build and cached, it is now included and all the
variables are extacted to that file. Now I simply use PHP. This saves
rendering time, also while teaching the web designer fundimental
programming. (He is only going to be working with simple items)

Mike

Frank

unread,
May 30, 2005, 12:00:26 PM5/30/05
to
WebRod wrote:
> Hi,
>
> i want to rewrite my website to separate the php script from the HTML code.
> Therefore a web designer can update the design of the website without any
> knowledge in PHP.
>
> I read a lot of information about several templates like PhpLib,
> FastTemplates, Smarty etc etc.
>*snip*

> My question is, what is the interest to learn another language??
> What is the real interest of Smarty (or other one)?

The only advantage I can see is that these things force you to separate
presentation logic from the rest of your code, as they aren't general
purpose enough to do all that php can.

Using php for templating doesn't require all that much restraint imo
(you know things will get messy really fast if you do things the ugly
way), so I'd never introduce one more layer of complexity.

> So I really think it's better to have;
> - a php script which set some variables
> - a HTML templates which build the content of the page. It uses a lot of
> HTML tags and of course some really basic php function (if, foreach, echo).
>
> Of course the php script call the HTML template.
> You only use php, you work with the same variables, you don't need to call
> some specific functions (assign etc etc), you don't need to know another
> language etc etc.

Agree completely. My php projects consist of a controller/request
handler step (usually with a front controller/dispatcher in front of
that) and a display step.

The request handler usually calls out to object oriented business logic
which builds some kind of data model, and then include() the proper
template (which may of course include other templates again, but no
other php code).
For very simple stuff I sometimes drop the oo stuff and manage with just
request handler and template.

rush

unread,
May 31, 2005, 5:23:54 AM5/31/05
to
"WebRod" <nom...@bouygtel.fr> wrote in message
news:429b1091$0$308$7a62...@news.club-internet.fr...
> Hi,

Now I see that you have posted separately to alt.php i comp.lang.php. To
make it short, there are template systems that do not have their own
separate language, yet they can do complicated things, whil offering
separation of html and php.

rush
--
http://www.templatetamer.com/
http://www.folderscavenger.com/


Chung Leong <chernyshevsky@hotmail.com>

unread,
May 31, 2005, 10:23:39 AM5/31/05
to
I've heard that said often enough: "separate out of the code from the
HTML so the web designer can work on it." In my experience it has never
worked out that way. Ususally the designer just hand me a Photoshop
file and I have to code the HTML myself.

I suspect that that's the norm rather than the exception. Designers
like to concentrate on the design, not having to think about the
technical stuff. Programmers are usually more able to actually
implement a design, especially when client-side scripting is involved.

R. Rajesh Jeba Anbiah

unread,
Jun 1, 2005, 1:17:31 PM6/1/05
to
Q: What is "template"?
A: It would usually mean the semi-pseudo-language on the top of PHP
that uses PHP. That means, it's a language/parser written in PHP (in
PHP world). Most of the template languages are markup-based.

Q: Why using templates?
A: The original purpose is to separate PHP code from HTML. But, the
idea is flawed as it wouldn't be possible at all. Some template engines
later claimed of separating business logic from presentation logic--but
not separation of PHP code from HTML (eg, Smarty). And this is highly
disputed--many PHP saints don't agree with templating concepts and they
use PHP. Interestingly, PHP is also a template engine.

To quote reader Chung Leong in
<news:qoGdnfJl2eL...@comcast.com>, "Using a template system is
a little like going back to using PHP 1--you get a far less powerful,
less flexible system to work with". And it remains one of the
controversial topic in PHP and recently there seems to be a declination
in the advocacy of template engines.

Refer:
http://www.phpbuilder.com/annotate/message.php3?id=1013434
http://www.phpbuilder.com/annotate/message.php3?id=1013711
http://www.phpbuilder.com/annotate/message.php3?id=1013461
http://www.phppatterns.com/index.php/article/articleview/4/1/1/
http://www.massassi.com/php/articles/template_engines/
http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf
<news:c17ndg$l3t$1...@newsreader.mailgate.org>

Q: How many template systems are available?
A: Lot--about or over 100.

Refer:
http://www.sitepoint.com/forums/showthread.php?threadid=123769

Q: What is the widely used template system in PHP?
A: PHP. PHP itself is a template system.

0 new messages