Smarty PHP Template Programming And Applications

Hasin Hayder, J. P. Maia, Lucian Gheorghe

  • 出版商: Packt Publishing
  • 出版日期: 2006-03-20
  • 售價: $1,550
  • 貴賓價: 9.5$1,473
  • 語言: 英文
  • 頁數: 256
  • 裝訂: Paperback
  • ISBN: 190481140X
  • ISBN-13: 9781904811404
  • 相關分類: PHP
  • 無法訂購

買這商品的人也買了...

商品描述

Description

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.

 

Table of Contents

Preface

 
  • 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
 
  • 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
 
  • 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
 
  • 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
 
  • 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
 
  • 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
 
  • Debugging Smarty Templates
  • Semantic Errors
  • Common Smarty Errors
  • Other Common Smarty Errors
  • Smarty Debug Console
  • Summary
 
  • 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
 
  • 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
 
  • 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
 
  • 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
 
  • 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
 

商品描述(中文翻譯)

Smarty是一個用於PHP的模板引擎。熟悉使用HTML文件的設計師可以使用Smarty模板,這些模板是帶有簡單標籤的HTML文件,而程序員則使用底層的PHP代碼。Smarty引擎將代碼和模板結合在一起。這樣的結果是設計師可以專注於設計,程序員可以專注於編程,他們不需要太多地互相干擾。即使您自己開發網站,Smarty也是一種使代碼更清晰、更容易調試和修改的強大方式。

目錄:
前言
第1章:介紹Smarty
- 模板系統
- 為什麼使用模板系統?
- Smarty的智慧之處
- Smarty的替代方案
- 軟體設計過程簡介
- 團隊合作:層次和關注點分離
- Smarty- PHP的終極模板系統
- Smarty的主要特點
- 變量修飾符
- 模板函數
- 調試
- 插件
- 過濾器
- Smarty內部
- 安裝和配置Smarty
- 升級Smarty網站
- 總結

第2章:Smarty網站架構
- 關注點分離
- 模板和代碼的結構
- 模板目錄結構
- 網站目錄結構
- 總結