Free Sample
+ Collection

Smarty PHP Template Programming and Applications

Hasin Hayder, Joao Prado Maia, Lucian Gheorghe

A step-by-step guide to building PHP web sites and applications using the Smarty templating engine
RRP $23.99
RRP $39.99
Print + eBook

Want this title & more?

$12.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781904811404
Paperback256 pages

About This Book

  • Bring the benefits of Smarty to your PHP programming
  • Give your designers the power to modify content and layout without PHP programming
  • Produce code that is easier to debug, maintain, and modify
  • Useful for both Smarty developers and users

Who This Book Is For

This book is written for PHP developers who want to use Smarty templates in their development, and for designers who are working with PHP developers who are using Smarty.

Table of Contents

Chapter 1: Introduction to Smarty
Templating Systems
A Rough Guide to the Software Design Process
Smarty—The Ultimate Templating System for PHP
Smarty’s Main Features
Smarty Internals
Installing and Configuring Smarty
Upgrading a Smarty Site
Chapter 2: Smarty Site Architecture
Separation of Concerns
Roles Involved in Building and Maintaining a Website
Starting a Smarty Project
Chapter 3: What Designers Need to Know
Development Team Problems: Common Scenarios
Roles of a Template Designer and a Programmer
Definitions and Concepts for Designers
Choosing an Editor for Template Design
Collaborating with Programmers
Chapter 4: Creating a Template
Design Concepts, from HTML to TPL
Introduction to Smarty Variables
Starting Templates
Basic Templating
Templates in the Real World
Chapter 5: Advanced Templating
Smarty under the Hood
Stretch your Imagination with Smarty
Available Modifiers
Combining Modifiers
Configuration Files
Chapter 6: Smarty Functions
Types of Smarty Functions
Functions in Action
Action: Re-using Page Elements with the include Function
Inserting Dynamic Content
Passing Variables to Included Templates
Saving Variables in Configuration Files
Creating Configuration Sections for Each Page
Handling Lists in Templates
Removing Extra White Space from Templates
Handling JavaScript Code in Templates
Processing Deeply Nested Arrays
Cycling Through a List of Values
Avoiding Spam Indexers
Form-Related Functions
More Form-Related Functions
Chapter 7: Debugging for Designers
Debugging Smarty Templates
Semantic Errors
Common Smarty Errors
Other Common Smarty Errors
Smarty Debug Console
Chapter 8: Built-in Smarty Variables and Methods
Built-in Smarty Variables
Built-in Smarty Methods
Chapter 9: Caching and Performance
Caching in Smarty
Dynamically Caching Template Sections
Clearing the Cache
Advanced Caching Features
Using Cache Groups
Clearing a Cache Group
Avoiding the Cache
Creating a Custom Cache Handler
Optimizing Smarty Applications
Profiling PHP
Designing Sites for Effective Caching
Tools: ApacheBench (ab)
Tools: Xdebug
Tools: WinCacheGrind
Chapter 10: Extending Smarty with Plug-ins
Finding and Installing Plug-ins
Useful Plug-ins
Writing your own Plug-ins
Plug-in Types
Registering Plug-ins
Example Plug-in: Calendar
Example Plug-in: Auto-link URLs
Chapter 11: Filters
Output Filters
Creating Filters
Registering a Filter at Run Time
Manually Loading a Filter
Automatically Loading a Filter
Filter #1: Remove HTML Comments
Filter #2: Benchmark Information
Filter #3: Compress Output with gzip
Filter #4: Search Engine Highlight
Chapter 12: Internationalization
Translation Infrastructure: Gettext
Configuring PHP with Gettext
Simple PHP Example
Setting Up the Gettext Files
Using Gettext with Smarty
Generating a PO File
Advanced Features of Smarty Gettext

What You Will Learn

This book is a comprehensive guide to all aspects of using Smarty. It will help you to:

  • Install and configure Smarty on your Web server
  • Understand how Smarty affects your web site architecture, and build site foundations that make the most of what Smarty offers
  • Designers will learn to work with templates that contain variables and logic, to modify layouts or content of Smarty web sites
  • See how Smarty caching can improve the performance of your sites
  • Develop custom Smarty functions and plug-ins to incorporate into your templates

In Detail

Smarty is a templating engine for PHP. Designers who are used to working with HTML files can work with Smarty templates, which are HTML files with simple tags while programmers work with the underlying PHP code. The Smarty engine brings the code and templates together. The result of all this is that designers can concentrate on designing, programmers can concentrate on programming, and they don't need to get in each others way so much.
Even if you are developing a site on your own, Smarty is a powerful way to make your code clearer to you and others, as well as easier to debug and modify later.

Visit the Free Online Edition for Smarty PHP Template Programming and Applications and learn more about the book and discover what each chapter from this book has in store.

You can now download "Smarty Cheat Sheet" for free:


Read More