ASPit - Totally ASP JSit - Totally JavaScript
Search PHPit

Use this textbox to search for articles on PHPit. Seperate keywords with a space.

Advertisements

Book Review: Smarty PHP Template Programming and Applications

(Page 1 out of 2)

Introduction

Welcome to the review of Packt Publishing's "Smarty PHP Template Programming and Applications" book. Smarty is one of the most popular templating systems for PHP, and it offers so much functionality that it certainly deserves its own book. Read on to learn more about this book.

Technical Details

Title: Smarty PHP Template Programming and Applications
Publisher: Packt Publishing
Authors: Lucian Gheorghe, Hasin Hayder, João Prado Maia
Length: 238 pages (12 chapters + index)
ISBN: 190481140X
Website: http://www.packtpub.com/smarty/book

The Review

This book is targeted towards two types of people: designers and developers, and it's hardly surprising that the book has been divided into a designer part and a developer part. The book first starts off with a general introduction on templating systems, and introduces Smarty and its main features. The first chapter also shows you how to download and install Smarty, which is not that difficult, and the book makes it even easier.

The second chapter is a chapter I really liked because it shows that this book is more than just a simple guide on Smarty. In this chapter the author explains why you should use Smarty, and uses good examples to demonstrate the need to separate concerns. The author then goes on to explain a basic MVC framework with Smarty, and each layer (model/data access, controller/business logic, view/presentation) is explained and demonstrated with good examples to show how they work. If you're a designer reading this book, you can pretty much skip this chapter, but if you're a developer, this chapter is a must-read, and I consider this to be one of the best chapters of the book.

Chapter three is the first chapter meant for designers, and provides an introduction to designing with a templating system, such as Smarty. The author explains the concepts you need to be familiar with (caching, optimization, etc), shows how to build up a page out of multiple templates, and gives a few recommendations for good template editors. Nothing earth shattering in this chapter, although if you've never worked with a templating system before this chapter is very useful for learning how to build up a page

Chapter four gets you started with the first actual template in which template variables are used. This chapter goes through all the basic functionality of Smarty, like using template arrays, logical conditions (if/then/else) and even loops to walk through an array of data. For a designer with no programming background whatsoever this chapter might be a bit overwhelming at first, since quite a lot of programming concepts are introduced, but everything is demonstrated with solid examples, so it should be easy to understand after a while.

This chapter also finishes with four useful real world examples, and you are shown how to create a calendar, a database report, a data input form and an email newsletter with Smarty and a few simple templates.

In chapter five you will be introduced to something called 'modifiers', which are used to format data in your templates. This chapter walks through every standard modifier in Smarty, and explains them with a simple example. The author also briefly explains how Smarty works under the hood. Not an amazingly useful chapter, and not a lot of new knowledge is introduced, but modifiers are a very important part of Smarty, so it's probably worth reading the first part of this chapter (where modifiers are explained) and then skipping the explanation of each individual modifier.

Chapter six talks about the use of 'functions', which is another feature of Smarty. Although this chapter does a good job at explaining what they are, and the author uses several good examples to demonstrate the use of functions, I've never had to use functions in my Smarty templates, and I've done plenty of wild stuff with my templates. Nonetheless, this chapter is still worth reading, although I have to warn that it might confuse designers at first, since functions are closer to developing than designing.

The final chapter of the designer's part, chapter seven, takes a look at debugging templates whenever something is wrong. Quite a small chapter really, and the author shows a few useful tricks to know exactly what's happening behind the scenes to diagnose any possible problems. Just like with the chapter six, this goes a bit beyond a designer's capabilities, and might be more suitable for a developer.

Next: Part Two & Final Verdict »



One Response to “Book Review: Smarty PHP Template Programming and Applications”

  1. PHPDeveloper.org Says:

    PHPit.net: Book Review: Smarty PHP Template Programming and Applications

Leave a Reply

About the author
Dennis Pallett is the main contributor to PHPit. He owns several websites, including ASPit and Chill2Music. He is currently still studying.
Article Index
  1. Details & Part One
  2. Part Two & Final Verdict
Bookmark Article
Download Article
PDF
Download this article as a PDF file