![]() |
[PHP] Hard Coded versus Template Engine
What would you prefer and why?
I started a iscript and know i hear my client wants hard coded content in the PHP File. Im trying him to change his mind but he is sure. I disagree on this because its a total mess and not easy to work with in the further. Just checking what people use this days. Im using template engines since 6-7 years ago. |
I would recommend templates. If a customer is set on hard coded content, explain to them why it's bad.
If they still insist on it - they are the customers so you have to do what they ask. If it takes longer to maintain you just charge them by the hour. |
We're left TEVS as hard code as it gives more freedom for webmasters to change it to how they want it. Some of the things iv seen I don't think you could ever use with a template system.
|
Quote:
|
Quote:
|
i like a template system, easy to change the design(s)
|
1) Give them hard coded files.
2) When it's time to update charge them an hour. 3) Client Bitches 4) Tell them you'll have to re-code it for a template system 5) Charge Them 10 hours |
It really depends on the amount of traffic the site is going to be getting. Template systems are costly to performance sometimes.
|
Somebody once said, PHP actually is a template system.
When you add another template system on top, you are creating an additional layer. With new syntax, additional learning curve and more limitations. I haven't met a person who can learn a template engine syntax (like Smarty or whatever), but can't learn the php syntax. p.s. I'm not personally against using template systems, I just have mixed feelings about it. |
Quote:
|
Quote:
|
A lot of schools of thought on this one...
Here's my take. Good code is good code, bad code is bad code... and there's a shitload of variance in between. Strip your function pages from your layout pages... That's just retard mode basics. Beyond that if a templating system such as smartys is going to allow you better cache/delivery options (a lot of subsequent db calls, looping code, whatever), and quicker updates use it... If per the project it's not a necessity, why code for shit that doesn't need to be coded for? |
Quote:
Im sure those people will disagree with you - par a few. |
Quote:
|
We was doing hardcoded for many years until the greatness of template engines came upon us.. And you still thinking to do hardcoded???
|
Quote:
He wanted the code to the admin files which we ZEND. The front end is raw (no template). |
Quote:
|
Quote:
I don't see any reason to change the way TEVs is doing things. |
Template Engine is good!
|
Quote:
|
Clean smarty templates are much easier to edit if you don't understand PHP at all.
|
Templating is the way to go if your using a CMS
|
Well Hans, I'm sure you already know my opinion :winkwink:
Smarty is the way I'd go for any PHP site I create. My main reasons: - Multi-lingual sites become much cleaner/easier (esp. with a few custom hacks to the smarty class allowing you to use the {l} tag) - Seperating code and html/design makes things cleaner and easier to work on in future. - When you want to ship off your templates for a redesign, it's a lot easier to have a designer not screw up your few simple smarty tags than working through your php code - WAP applications as well as other functionality is made much easier with Smarty's functions I'm sure there are tons of other reasons I could think of if the above wasn't enough. |
I REALLY dislike template engines, and I prefer to create header/footer files and seperate my php code from the html as much as possible.
If a user can type {$title} in a template, they can just as easily type $row[title]. When doing loops, more people know and understand how to do them in PHP then in smarty. |
there a couple questions involved before the decision of hard coded or template comes into play. There is a time and place for both.
|
I recommend templates. It's simple and can save lots of time.
|
Depends on what you mean. Generally design should be separate from code. This is a basic principle of MVC that has been established as a best practice for more than a decade.
However, just because someone doesn't use a template doesn't mean they aren't separating their design from their code. There are many more ways than templates to accomplish this. In fact, I rarely use templates because I find them very inefficient (from a development standpoint), the only exception is when I need to expose template type functionality to an end user where they will be coming up with a different design on a daily basis (like email newsletters or something). The books "The Pragmatic Programmer" or "Code Generation" have some good ideas of other ways to go about things. I highly recommend them. |
Quote:
|
Quote:
|
All times are GMT -7. The time now is 06:54 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc