Smarty haters

Anti-testimonials

We’re not the only ones that hate Smarty.


Don’t be too hard on Smarty! It served many of us well in its day. Sure, there are few good reasons to use Smarty today. Before there were viable MVC frameworks in PHP, Smarty provided developers with a way to separate business logic and presentation. Let’s at least give smarty a decent burial and a little respect for the value it used to provide! :-)

Chris Chrissy
When our developer install smarty on our server I didn’t question it at all. We are a New York escort service and our customers make appointments to see females for company in the New York area. Our page for Bronx escorts had an online booking for that clients can use to make an appointment with an escort. The form gets sent direct to the female escort and she is able to contact the client and confirm the booking for the selected dates. The appointments were getting all mixed up and there were some that did not make it. Our escorts were fuming. They had dates lined up with clients from all over NYC that they could not confirm. We tried to save them but the escorts resorted to good old fashioned person to person contact — they called everyone up one by one. The escort in NYC are resilient and thanks to them we worked it out and got rid of smarty.

When I was told our team was to start using smarty I was really hesitant, however once I found out I would have to learn a whole new syntax I was quickly persuaded.

continue reading this article

Is smarty right for me?

No. Despite its name, Smarty is not the most intelligent solution available to you.

It’s true that Smarty has received numerous testimonials over the years. However, it’s clear that most of these testimonials are from developers who are unfamiliar with multitier architectures. For these users, the concept of separating business logic and presentation is (understandably) an innovative concept. But Smarty is only one such way of achieving this separation, and no longer the best alternative available (if it ever was).

Smarty has a list of benefits on its website. Let’s go through some of them and shoot them down.

Caching

Here’s what Smarty says:

Smarty provides fine-grained caching features for caching all or parts of a rendered web page, or leaving parts uncached. Programmers can register template functions as cacheable or non-cachable, group cached pages into logical units for easier management, etc.

OK, so let’s take a look at Smarty’s caching system. To enable caching, you would write

$smarty = new Smarty(); $smarty->caching = 1;

This sets up caching with the default lifetime of 3600 seconds (that’s one hour). What if you want to use an alternate TTL–say, 30 minutes? Then you would write

$smarty = new Smarty(); $smarty->caching = 2; $smarty->cache_lifetime = 1800;

Oh, of course, $smary->caching = 2;. What else would it be? Well, a constant instead of a magic number would be nice. But wait, why does the TTL even depend on a magic number being set for caching? If caching is going to be accessed directly through a public property of Smarty, shouldn’t it at least be a simple Boolean, either true or false?… continue reading this article

Why MVC

It turns convenience could be get after using a framework that implements the MVC when want to hold a variety of changes in a web application. If Engadget-Engadget while still using pure PHP, ya when ya want to change the look of the web should be recast here and there. Moreover, the application that I want to modify it to include function to display and perform database operations.

Knowingly wrote, because it created time application first learned so yes it is so. The most important thing at that time was able to make something first. The issue would later be modified and blablabla still haven’t thought through. Over time will be improvements here and there whether it’s from the ease of setting, ease of modification and of course security.

Back to the matter of framework that implements MVC, when want to change the appearance of an application then the live edit . Or else, you can also create a new view and then live loader view change in the controller. If using a Template Engine like Smarty not know because never tried it before and still enjoy the manual CSS. So not have to edit here and there is really no need to. By using a framework that implements MVC, then it’s obvious where the put function to display the function for the database, etc.

When you want to change the look, Yes just replace the view or the loader on a controller that is associated with the view in question.

continue reading this article

Base URL in CI

The best way to accomplish this is to overwrite the line in config.php with the following code:

$config['base_url']    = 'http://'.$_SERVER['HTTP_HOST'].'/';

If in your config you are using sub folders then use following code:

$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url']    = "$root";

continue reading this article

Securing your CI based site

Error reporting might something you face while building site with CI.
It turns out when the application is running and there is an error, then the error is reporting that others still displaying error messages that could be injurious to the application that you have created.

Error reporting what I mean is when an error occurred when accessing the database table you are referring to for example turned out to be no (does not exist or you incorrectly typed in its name), the number of columns does not match the database insert error, etc. then the CodeIgniter will display error which of course took part showing database name and some other information. This will be beneficial when the error is encountered you as an administrator but would harm while viewing this kind of error is visitors or anyone else that we don’t know what it will do with the information he got.… continue reading this article

Within CI, CakePHP and Zend

Within CI, CakePHP, and Zend, three of it had its own benefit and fans, but which one you desire its all about how much you get comfortable with and the main purpose developing the sites.
For more information about the three of it, check it out below:

1. CodeIgniter
impression: perhaps this is the Framework that has the fastest compared to other Framework accessibility.
Pros:
-Performance in executing the very fast
-Supports PHP4 and PHP5
-Complete Documentation
-Easy to learn (he ‘s).… continue reading this article

Force Download in CakePHP

Below are some script code that might be useful for you whom had tried to do force download in cakePHP.
Okay no more further talking, find it below:

function download($id = null){
$file = $this->Download->findById($id);
$direktori = “files/downloads/”;
$filename = $file[‘Download’][‘namafile’];
$extension = strtolower(substr(strrchr($filename,”.”),1));
switch($extension)… continue reading this article

Search Form with cakePHP

how the hell is a way to make the data based on the search form field using the CakePHP Framework?.. actually this discussion will also be discussed at a follow-up edition of CakePHP books (complete with Highlighting techniques). just wait yes its presence. ^^

For instance, we have a table with the name searches with each field as follows:
id | INT | Autoincreament | PrimaryKey
nim | Varchar | 10
the name | Varchar | 100
the city | Varchar | 100… continue reading this article

Smarty PHP

Smarty is a template engine for PHP, very useful for separating logic and layout work is work. The bottom line using Smarty then it’s very easy for us to do to customize the web interface should display website (template) made changes.

The author sometimes confused myself re-layout of each block or the sidebar, because logic and layout are still incorporated into one. example of job logic and layout are still incorporated you can look at the following script:… continue reading this article