Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

How: I do not need a html template for website programming

Post new topic   Reply to topic    Smarty Forum Index -> Article Discussions
View previous topic :: View next topic  
Author Message
Smarty Elite

Joined: 19 Apr 2007
Posts: 423

PostPosted: Sun Mar 01, 2009 7:31 pm    Post subject: How: I do not need a html template for website programming Reply with quote

This article is available at:

How: I do not need a html template for website programming

Smarty modifies the website building process. Over a longer period of time, I experienced it as a nice tool and as a poor tool. So, here, I am writing my views on Smarty.

In this article, I will be discussing on:
Why Smarty?
Cost of development time
Designer quickly learns to work with templates for Smarty
Smarty is for from-scratch projects only
Smarty is independent
Carry on abandoned projects

For a beginner, it is not a good tool to use because, it makes confusion elsewhere. I now laugh at the code I wrote with Smarty four years back. And, I do not have enough time to fix it too.

On the other hand, I have lead many large scale applications based on Smarty while in an office. I find a lot of tricks for Smarty in every new project I work with. And, now, I am in love with Smarty.

Here I describe few challenges faced during my past time developments:

Why Smarty?
This was a common question asked for each new project I led. My manager and the client asked me. Before starting any project, I needed to give a detailed explanation. This sentence convinced anyone in an average – If you are not using any template in your website, it is a worthless, and when you use a template engine, Smarty is best.

If I am a non-responsible developer, I can choose Smarty just to solve the templating problems, and make the project abandoned. But for serious and transparent work, I train the colleagues and clients how to use the files for necessary modification, without asking my team.

If you do not plan well in advance, how to manage the file structures of your website system, Smarty is the worst tool for you. In fact, it is your mistake only. If you can not work with Smarty, quit it, and try with other template engines you know.

Don’t let me know later that you did not sophisticated systems with other things. Even the manual tells that Smarty has many things than just variable replacements.

Cost of development time
In an offshore business, every time is important, and sometimes, costlier. So, for low budget clients, Smarty can offer a big chance to have quicker template integration. An experienced programmer can easily mix-up with the designer’s files and make your application ready. This saves a significant time.

Designer quickly learns to work with templates for Smarty
Once I gave a very strong warning to one of my designer – You CANNOT use the curly braces { and } in an HTML file. That was perfect solution for me. For many beginners, this is a great havoc. To obey my warnings, he just externalized the CSS and necessary Javascripts.

Now, there are no complains from a designer. If I say, it is for a Smarty based projects, he is already aware of it. This formed a nice team, self understood.

Smarty is for from-scratch projects only
Yes. Choose Smarty only if you have to work from the scratch works. You can not change the traditionally written projects into Smarty base, in a day. But if you are planning to start a FRESH project, always think of Smarty. So, it helps custom coded projects develop faster.
However, if you would like to use Smarty for minor tools, you may use, but just think of the relevance.

Smarty is independent
You must focus on writing/building classes and objects properly. For a real web programmer, there is NO need to have a single line of HTML output. Let this become the aspects of designs only.

Here is my example scene to understand how you can simulate a NO-HTML website for a membership management. (The details and description is out of the scope of this article section)

Take an object that is able to add user data, activate the user, login and change the password. These may be implemented as:

$user->add_user(), $user->activate_user(), $user->login(), $user->change_password().

Remember, there are few super global variables in PHP. Some of them are: $_GET, $_POST, $_SESSION, and more. You can read write into these variables from anywhere (within a function, method, an included file, elsewhere). This feature sometimes lets you build a parameter-less functions.

If you expect a login function to be like, $user->login($username, $password), then, it can be even without the parameters as:

function login()
   $success = false;

   $username = isset($_POST[‘username’])? ($_POST[‘username’]:’’;
   $password  = isset($_POST[‘password])? ($_POST[‘password]:’’;
   # Check in the database, and see, if to send true or false for $success.


For these features to be implemented, you DO NOT need the HTML templates (Smarty templates), neither the HTML forms with submit button, etc. Hence, you can continue, even if you do not have proper HTML templates ready for you to work.

This is the difference with Smarty. For the traditional programming, they need a finally approved template / designs to start a work. While with Smarty, you can implement a design at the last moment only.

Carry on abandoned projects
Sometimes, they hire a web programmer to work on an abandoned project. They may be wishful to pay higher for this, but they may not explain it well in advance; if you will have to work on an abandoned project.

This makes life hurried, because you will have to answer for somebody else’s mistake. In my experience, projects even if were abandoned, it is easier to takeover, if it was written with Smarty. Otherwise, there is no proper guarantee for the control.

Smarty at least offers to structurize how to access to the basic programming, and the design issues. Modifiers and other template functions are rare, but easily noticeable to an experienced person.

So, if you know that you will need to have somebody else (unrelated person) will have to work for your projects, please force using Smarty. But the final choice is yours.

Smarty is free of application logic
You do not need somebody to complete design or Smarty works. If you follow certain practices, your project is a complete package first, without designs and user interactive works. Rarely, few items rely on plugins. But you should start an independent work for your website.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Article Discussions All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP