Chapter 6. Smarty Functions

Smarty provides a wide variety of functions available to you as a template designer to use as part of your templates. While you may never use some of these functions, it is important to get to know their functionality, as they were created with the ultimate goal of solving everyday problems of web developers.

As a rule of thumb, if you need some functionality in your templates and you don’t know for sure if Smarty already provides it, check if there is already a function for it. If you require some custom functionality, consider writing a Smarty plug-in.

In this chapter you will learn about the different types of functions available in Smarty, a list of those functions and examples of their use, and how to extend Smarty and create your own functions.

Types of Smarty Functions

Smarty as a software project tries to be simple and this is seen in the built-in functionality that is shipped by the template compiler and parser. The template language is itself built on functions that enable the basis of the functionality of a template, and you can extend the standard functionality of Smarty with plug-ins. However, the built-in functions cannot be modified and you cannot create custom functions with the same names.

Since the development team knew that they couldn’t predict all uses of Smarty, or all needed functions, they decided to create a plug-in architecture and let the end users create, modify, and submit new plug-ins. Most of the Smarty functions are themselves implemented using this very plug-in architecture.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.0.192