Skip to Content

Smarty PHP Template Programming and Applications


Table of Contents

Preface
Chapter 1: Introduction to Smarty
Chapter 2: Smarty Site Architecture
Chapter 3: What Designers Need to Know
Chapter 4: Creating a Template
Chapter 5: Advanced Templating
Chapter 6: Smarty Functions
Chapter 7: Debugging for Designers
Chapter 8: Built-in Smarty Variables and Methods
Chapter 9: Caching and Performance
Chapter 10: Extending Smarty with Plug-ins
Chapter 11: Filters
Chapter 12: Internationalization
Index

  • Chapter 1: Introduction to Smarty
    • Templating Systems
      • Why Use a Templating System?
      • The Smartness of Smarty
      • Smarty Alternatives
    • A Rough Guide to the Software Design Process
      • Working in Teams: Layers and Separation of Concerns
    • Smarty—The Ultimate Templating System for PHP
      • Is Smarty Fast?
      • Is Smarty Secure?
    • Smarty's Main Features
      • Variable Modifiers
      • Template Functions
      • Debugging
      • Plugins
      • Filters
    • Smarty Internals
    • Installing and Configuring Smarty
      • Step 1: Obtaining Smarty
      • Step 2: Configure PHP to Find the Smarty Libraries
        • On Windows
        • On Linux
      • An Alternative to Step 2: Using Smarty without Having Full Access to the System
      • Step 3: Set Up Smarty for Your Application
      • Step 4: Verifying the Installation
      • Smarty Development Versions on CVS
    • Upgrading a Smarty Site
    • Summary
  • Chapter 2: Smarty Site Architecture
    • Separation of Concerns
      • What Does Concern Mean?
      • A Problem-Solving Perspective
      • Cross-cutting Concerns
    • Roles Involved in Building and Maintaining a Website
    • Starting a Smarty Project
      • Directory Structure
      • Securing our Smarty Project
      • The Data Access Layer
        • How it Works
      • The Business Logic Layer
        • How it Works
      • The Presentation Layer
        • How it Works
      • The Result
    • Summary
  • 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
      • Concept of Reusability and Components
      • Splitting into Components
      • How to Design Table-less Layouts?
      • Handy Built-in Tags
    • Choosing an Editor for Template Design
    • Collaborating with Programmers
    • Summary
  • Chapter 4: Creating a Template
    • Design Concepts, from HTML to TPL
    • Introduction to Smarty Variables
    • Starting Templates
      • Nonassociative Array
      • Associative Array
      • Passing Arrays to Smarty Templates and Manipulating Them
    • Basic Templating
      • Logical Conditions
      • Loops
        • section
        • foreach
    • Templates in the Real World
      • Calendar
      • Database Report
      • Data Input Forms
      • Email Newsletter
      • Running PHP Code Inside your Templates
    • Summary
  • Chapter 5: Advanced Templating
    • Smarty under the Hood
      • Compile Steps
      • Prefilters and Postfilters
      • What is a Smarty Modifier?
    • Stretch your Imagination with Smarty
      • Student Transcript
      • Photo Gallery
    • Available Modifiers
      • capitalize
      • count_characters
      • cat
      • count_paragraphs
      • count_words
      • date_format
      • default
      • escape
      • indent
      • lower
      • upper
      • nl2br
      • regex_replace
      • replace
      • spacify
      • string_format
      • strip
      • strip_tags
      • truncate
      • wordwrap
    • Combining Modifiers
    • Configuration Files
    • Summary
  • Chapter 6: Smarty Functions
    • Types of Smarty Functions
    • Functions in Action
      • Action: Re-using Page Elements with the include Function
      • Explanation
  • 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
  • Summary
  • Chapter 8: Built-in Smarty Variables and Methods
    • Built-in Smarty Variables
      • $template_dir
      • $compile_dir
      • $config_dir
      • $plugins_dir
      • $debugging
      • $error_reporting
      • $debug_tpl
      • $debugging_ctrl
      • $compile_check
      • $force_compile
      • $caching
      • $cache_dir
      • $cache_lifetime
      • $cache_modified_check
      • $php_handling
      • $security
      • $secure_dir
      • $security_settings
      • $trusted_dir
      • $left_delimiter
      • $right_delimiter
      • $request_vars_order
      • $request_use_auto_globals
      • $compile_id
      • $use_sub_dirs
      • $default_modifiers
      • $default_resource_type
      • $cache_handler_func
      • $autoload_filters
      • $config_overwrite
      • $config_booleanize
      • $config_read_hidden
      • $config_fix_newlines
      • $default_template_handler_func
      • $compiler_file
      • $compiler_class
      • $config_class
    • Handy Built-in Smarty Variables Table
  • Built-in Smarty Methods
    • assign
    • assign_by_ref
    • Example: Working of assign and assign_by_ref
    • append
    • append_by_ref
    • clear_assign
    • register_function
    • unregister_function
    • register_object
    • unregister_object
    • register_block
    • unregister_block
    • register_compiler_function
    • unregister_compiler_function
    • register_modifier
    • unregister_modifier
    • register_resource
    • unregister_resource
    • register_prefilter
    • unregister_prefilter
    • register_postfilter
    • unregister_postfilter
    • register_outputfilter
    • unregister_outputfilter
    • load_filter
    • clear_cache
    • clear_all_cache
    • is_cached
    • clear_all_assign
    • clear_compiled_tpl
    • template_exists
    • get_template_vars
    • get_config_vars
    • trigger_error
    • display
    • fetch
    • config_load
    • get_registered_object
    • clear_config
  • Summary
  • 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
      • The LastModified and ETag Headers
      • The Expires Header
      • The CacheControl Header
  • Tools: ApacheBench (ab)
  • Tools: Xdebug
  • Tools: WinCacheGrind
  • Summary
  • Chapter 10: Extending Smarty with Plug-ins
    • Finding and Installing Plug-ins
    • Useful Plug-ins
      • HTML List Plug-in
      • File Size Format Plug-in
      • Google Highlight Plug-in
    • Writing your own Plug-ins
    • Plug-in Types
      • Functions
      • Modifiers
      • Block Functions
      • Compiler Functions
      • Prefilters, Postfilters, and Output Filters
      • Resources
      • Inserts
    • Registering Plug-ins
    • Example Plug-in: Calendar
    • Example Plug-in: Auto-link URLs
    • Summary
  • Chapter 11: Filters
    • Prefilters
    • Postfilters
    • 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
    • Summary
  • 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
    • Summary

[ AddThis ]

Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Open Source Content Management Customer Relationship Management e-Commerce e-Learning Java Linux Servers Networking & Telephony PHP Web Graphics & Video Web Development
Enterprise BPEL Microsoft Oracle SOA Web Services
Other Packt Books .Net Web Graphics & Video Beginner Guides Cookbooks