Template Engine
Moderator: General Moderators
-
anthony88guy
- Forum Contributor
- Posts: 246
- Joined: Thu Jan 20, 2005 8:22 pm
Template Engine
I've never used a Template Engine for my projects but I've worked with some. I'm interested in working with Smarty, but is it possible with a shared host?
If you view the Smarty quick install guide it looks like you need shell access? Which I don’t have. Is there another way I could install it? Or another Template Engine I could use?
If you view the Smarty quick install guide it looks like you need shell access? Which I don’t have. Is there another way I could install it? Or another Template Engine I could use?
Re: Template Engine
Absolutely.anthony88guy wrote:I've never used a Template Engine for my projects but I've worked with some. I'm interested in working with Smarty, but is it possible with a shared host?
No, they just use that as the example because its easier to show what to do. You can also ftp the files into a shared host, and access them that way. There is no need for shell access.anthony88guy wrote:If you view the Smarty quick install guide it looks like you need shell access?
I've recently used Smarty for the first time, I love it
Very easy to use.
Not tried templatelite yet though.
Have previously used just plain old PHP for templating, but sometimes find myself getting in a blur between the presentation and business logic, with the difference in syntax (and [deliberate] limitations) with the Smarty syntax, that is no longer a problem for me.
Not tried templatelite yet though.
Have previously used just plain old PHP for templating, but sometimes find myself getting in a blur between the presentation and business logic, with the difference in syntax (and [deliberate] limitations) with the Smarty syntax, that is no longer a problem for me.
- mikealeonetti
- Forum Newbie
- Posts: 5
- Joined: Wed Sep 06, 2006 2:52 pm
- Location: Long Island
Well the "business logic" and the presentation need not be so far apart. In a perfect world all people who have the ability to design well could work around PHP no problem, but that is in the perfect world. But, if we take logic out of the template code then everything becomes more difficult. I've tried writing a template engine myself that tries to incorporate the easier ends of both. Making things readable and easier on both the designer and the programmer without sacrificing speed (not too much) and readability. Although there was a heck of a lot of support for smarty, it just didn't do it for me.
There are too many template systems out there, and the newer ones just get blown away by smarty. Wish we could get them all together at one domain and give them all a sub-domain so they'd be easier to choose for people.
There are too many template systems out there, and the newer ones just get blown away by smarty. Wish we could get them all together at one domain and give them all a sub-domain so they'd be easier to choose for people.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
I think you mean 'presentation logic' and the template need not be so far apart. The 'business logic' should be kept well apart in my view.mikealeonetti wrote:Well the "business logic" and the presentation need not be so far apart.
I agree.mikealeonetti wrote:There are too many template systems out there, and the newer ones just get blown away by smarty. Wish we could get them all together at one domain and give them all a sub-domain so they'd be easier to choose for people.
(#10850)
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
There are also two sides to this discussion, yes templates can be helpful to use for a multidude of reasons, but at the same time they are not neccesarily required or desired. I personally have made the shift to template engines, and back to using standard php. Personally, I don't like having to learn new markup and having the overhead of the template itself, but at the same time a proper caching implementation can reduce overhead greatly.
This is a holy war I'm treading on here, but I thought it important to make a quick remark that there are those of us who do not use them.
This is a holy war I'm treading on here, but I thought it important to make a quick remark that there are those of us who do not use them.
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Performance isn't an issue with smarty its got very good caching. But I agree totally with you on the learning issue and so I've never learnt smarty or anything like it. I probably should give it a go one day.Personally, I don't like having to learn new markup and having the overhead of the template itself, but at the same time a proper caching implementation can reduce overhead greatly.
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
The concept of a template engine makes sense, but like already said many times before...Smarty is over kill...with a little bit of discipline you can utilize PHP's inbuilt templating functionality, write your own custom caching for much better performance and still get that seperation everyone talks about without having to learn another syntax (Smarty, etc).
As for a single unified list of every template engine: http://www.sitepoint.com/forums/showthr ... did=123769
Poke around the wiki as well: http://en.wikipedia.org/wiki/Template_engine
Cheers
As for a single unified list of every template engine: http://www.sitepoint.com/forums/showthr ... did=123769
Poke around the wiki as well: http://en.wikipedia.org/wiki/Template_engine
Cheers
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
It's not just that I refer to when I speak of performance...ole wrote:Performance isn't an issue with smarty its got very good caching. But I agree totally with you on the learning issue and so I've never learnt smarty or anything like it. I probably should give it a go one day.Personally, I don't like having to learn new markup and having the overhead of the template itself, but at the same time a proper caching implementation can reduce overhead greatly.
It's like using any library thats big it adds bloat...Zend Framework is big and even though not all files are used at any given moment, it still adds unessential parsing, etc to your scripts execution...so it does, decrease performance...
You have to balance the time is development with the cost of new hardware...which for me, it's easier to just keep using PHP as it's own template system, it's fast, and only requires moderate discipline (I should take as most projects begin slipping logic into presentation
Cheers
- mikealeonetti
- Forum Newbie
- Posts: 5
- Joined: Wed Sep 06, 2006 2:52 pm
- Location: Long Island
Well, I believe that when a template is done correctly and it "compiles" he template files into PHP a lot of nasty overhead can be avoided. In this way the only real overhead in the code might result from string indexed arrays. And it is possible to make template syntax as easy as pie by making commands as you expect them to be and letting the code flow be more natural. In reality, more commands, more functionality, more of something doesn't necessarily make things better.
Plus I had a problem a while back because Smarty wouldn't let me embed array loops and I had to write something myself anyway.
Plus I had a problem a while back because Smarty wouldn't let me embed array loops and I had to write something myself anyway.
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Smarty doesn't support array loops???
You weren't using AdoDB were you?
Smarty just plain old sucks...
Yes it has caching, but not intelligent caching...it's generic caching for the most part, extendible sure, but so is PHP as a native template langauge...
Smarty might compile but they also fail to inform people that the web pages which need caching the most, like search results on a classified site or a threaded message forum, etc...can't really be cached without programming some custom event caching system, which is difficult to do regardless whether you use Smarty or not...
Static boring pages like 'about us' that no one every reads is easy to cache, and is why Smarty is advertised as this advanced compiler type template system...when in reality it's a glorified excuse for OOP in PHP
Thats my story
You weren't using AdoDB were you?
Smarty just plain old sucks...
Yes it has caching, but not intelligent caching...it's generic caching for the most part, extendible sure, but so is PHP as a native template langauge...
Smarty might compile but they also fail to inform people that the web pages which need caching the most, like search results on a classified site or a threaded message forum, etc...can't really be cached without programming some custom event caching system, which is difficult to do regardless whether you use Smarty or not...
Static boring pages like 'about us' that no one every reads is easy to cache, and is why Smarty is advertised as this advanced compiler type template system...when in reality it's a glorified excuse for OOP in PHP
Thats my story
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
OK I'm going to have a bit of a rant here. I accept that quite a few people won't agree with this but I think it needs to be said.
If you really cared about performance you would be writing your web applications in C++. The idea is you use each language to the best of its abilities. What is clearly wrong is that people use the performance arguement as an execuse not to learn new stuff or improvement their programming style.
I remember thinking that there was a 50 50 split in PHP with procedural and OO programmers. Procedural programmers claiming to not need OO features and valuing performance more than OO ones. When I went to the first PHPLondon, which is full of high end developers, everyone used OO code heavily and shunned procedural as being a pretty redundant methodology on any PHP 5 enabled server. Some of them talked about some really high level abstractions, which caused a lot of interest here when I reiterated them to you. Why? Because:
So returning to the Smarty argument. If you think you have use for it and you like it, use it! If you don't think it will make your life easier don't!
and having the overhead of the template itself
People place far too much importance on performance. PHP is a high level language that we use because it makes our jobs easier. Libraries are just an extension of this. You deal with performance only when performance becomes an issue by using profiling, at which point you will likely find well written libraries are not the culprit.It's like using any library thats big it adds bloat...Zend Framework is big and even though not all files are used at any given moment, it still adds unessential parsing, etc to your scripts execution...so it does, decrease performance...
If you really cared about performance you would be writing your web applications in C++. The idea is you use each language to the best of its abilities. What is clearly wrong is that people use the performance arguement as an execuse not to learn new stuff or improvement their programming style.
I remember thinking that there was a 50 50 split in PHP with procedural and OO programmers. Procedural programmers claiming to not need OO features and valuing performance more than OO ones. When I went to the first PHPLondon, which is full of high end developers, everyone used OO code heavily and shunned procedural as being a pretty redundant methodology on any PHP 5 enabled server. Some of them talked about some really high level abstractions, which caused a lot of interest here when I reiterated them to you. Why? Because:
- It make their jobs easier
- Programmer time is often more expensive than RAM/CPU upgrades
- The most effective performance increases come through profiling for bottle necks and are pretty specific to each deployment
- A lot of performance bottle necks will be at data level
- Peformance isn't always major issue
So returning to the Smarty argument. If you think you have use for it and you like it, use it! If you don't think it will make your life easier don't!
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Performance will be an important issue until computers are completely automated...yes it's less and less so every year, but why add bloat when you don't need too???People place far too much importance on performance. PHP is a high level language that we use because it makes our jobs easier. Libraries are just an extension of this. You deal with performance only when performance becomes an issue by using profiling, at which point you will likely find well written libraries are not the culprit.
Thats just naive and bad programming practice IMHO. Why not just have random LOOPs inside your code:
Code: Select all
for($i=0; $i<10000; $i++);Nothing is wrong with templating, I use a PHP variation all the time and have done so for long time. Smarty doesn't offer enough features (which can't be easily emulated using straight PHP) to justify it's cost...
I would argue however that Zend Framework does offer enough benefits to justify it's cost in performance hit.
Smarty basically just assists the presentation layer in helping keep business logic out of it's scope...you can still shoot yourself in the foot however using {php} tags...so really, your just as likely to do so, then if you were going to intermingle logic using straight PHP template engine.
Also, Smarty, from what I remember...IMHO anyways, supports bad design practices...
Keeping the formatting of date/time in the presentation layer is bad...it's likely going to be hardcoded in some format which your used too. Month.day.year - year.month,day, etc...
You could possibly store that value in a smarty config file, but IMHO it's easier to let the business logic determine the formatting of such values, so changes made in the admin section will propagate througout the website immediately. This way you can store your formatting details in DB, config files, XML, etc...
Smarty simply doesn't offer enough advantage to justify it's use...read my previous argumentsIf you really cared about performance you would be writing your web applications in C++. The idea is you use each language to the best of its abilities. What is clearly wrong is that people use the performance arguement as an execuse not to learn new stuff or improvement their programming style
I'm like water my friend...I follow the path of least resistence all the time...I'm just lazy that wayAs programmers we should take the easiest, most flexible/adapatable path in an effort to write maintainable code that has fewest bugs. If performance is important you profile and make modifications where it is necessary.
Your arguments are valid, but out of context amigo. Yes, we should adapt to new methodologies and make better use of our time, agreed. But we also shouldn't use something based on the fact some one told us that it's the cats meow, until you fully understand what it is it's offering. Thats called naievty I think.
If someone told you to jump off a bridge, would you follow or think it through first?
Personally I'd always go with the latter
Smarty, although in theory sounds awesome, in pragmatic terms it's nothing more than a glorified version of native PHP template engine, doing nothing but eating clock cycles and chewing RAM by the mega byte.
Template lite is an optimized version of of Smarty which solves some issues of performance, but still doesn't justify using it for anything other than experimentation and research.
If they excluded the {php} at least you would have the argument that it *prevents* not just assists in helping the presetnation logic from mixing with business logic. But they can't do that because logic is occasionally required in both business/presetnation. So why learn a new syntax, which IMHO is kludgey to begin with, when I can just use what I already know, PHP???
Cheers
Hockey wrote:Your arguments are valid, but out of context amigo.
Oles arguments are perfectly on topic, contrary to what you are offering, hockey. You are mostly directly engaging with Ole as a person, not with the arguments he put forward.
There are estimates that 80% of development time is nowadays used for maintenance, 20% for creating code from scratch. Point is: if the code had been written for humans first and computers second, there would be more time to innovate.Hockey wrote:Yes, we should adapt to new methodologies and make better use of our time, agreed. But we also shouldn't use something based on the fact some one told us that it's the cats meow, until you fully understand what it is it's offering. Thats called naievty I think.
Hardware is dirt-cheap, will get even faster, smaller and with more capacity and bandwidth. Good developers won't get faster, won't get cheaper (on the contrary), won't get smaller and their capacity will cap at some point.
On a meta-level: tone down statements that can be interpreted personal attacks, hockey.