Smarty. PHP Template Programming and Applications.pdf
Smarty. PHP Template Programming and ApplicationsSmartyPHP Template Programming and ApplicationsobvrInto 2006 Packt PublishingAll rights reserved No part of this book may be reproduced, stored in a retrieval system, ortransmitted in any form or by any means, without the prior written permission of the publisher,except in the case of brief quotations embedded in critical articles or reviewsEvery effort has been made in the preparation of this book to ensure the accuracy of thenformation presented. However, the information contained in this book is sold without warrantyeither express or implied. Neither the authors, Packt Publishing, nor its dealers or distributors wilbe held liable for any damages caused or alleged to be caused directly or indirectly by this bookPackt Publishing has endeavored to provide trademark information about all the companies andproducts mentioned in this book by the appropriate use of capitals. However, Packt Publishingcannot guarantee the accuracy of this informationFirst published: April 2006Production reference: 1050406Published by Packt Publishing Ltd32 Lincoln roadOltonBirmingham, B27 6PA, UKISBN1-904811-40-XWww.Packtpub.comCoverdesignbywww.visionwt.comCreditsAuthorsDevelopment EditorJoao prado maiaDavid barnesHasin HayderLucian GheorgheIndexerAshutosh pandeReviewerMizanur rahmanProofreaderChris smithTechnical editorRushabh SanghaviProduction coordinatorManjiri NadkarniEditorial ManagerDipali chittarCover DesignerHelen woodAbout the authorsJoao Prado maia is Lead Software Developer with Alert logic, Inc and was previously withMySQL AB as the lead developer behind Eventum, an issue tracking system, and MySQLNetwork, a subscription product for everything related to MySQL services. He has beenworking with PHP, Smarty, and Pear for several years, and maintains phpbrasil. com, one ofthe most popular PHP-related community sites in Brazil. He is also interested in fostering acommunity of PhP developers in Houston by organizing the Houston PHP Users Group athttp://houstonphp.orgI would like to thank my wife for her encouragement and patience while I was writingchapters for this book. I dedicate my work to you, JulianaHasin Hayder graduated in Civil Engineering from Rajshahi University of Engineering andTechnology (RUET). He is an open-source enthusiast who has been programming since early2001. He maintains php Xperts, the largest PHP user group in Bangladesh, and Zephyr, anopen-source AJAX-based MvC framework for PHP5 developers. He is currently working as aweb application developer in a norwegian software development company Somewhere InYou can reach him at hasinasomewherein netI would like to thank my editors from Packt Publishing, David Barnes, Rushabh Sanghaviand Patricia Weir for this book. Without them I doubt I would have completed my chaptersso easily. I would also like to thank Damian and Arnab in Packt Publishing for their helpThanks also go to Mom, Dad, all my family members, Mahbub bhai, Rashidul Hasan andall my friends for supporting me. And finally I would like to thank ashikuzzaman Fahim andArild Klokkerhaug, who inspire me a lotI would like to dedicate this book to my wife and my best friend ayesha I know I could note here without youLucian Gheorghe is currently working as a senior network engineer for Globtel Internet,asignificant Internet and Telephony Services Provider to the romanian market. Even if it's not hismain activity, He has been programming in PHP for over 5 years building billing interfaces,industrial software interfaces, e-commerce sites, and so on. He had a lot of help from a friendcalled Smarty in his programming experiencesLucian got his first taste of writing when he contributed a few chapters to the book beginninPHP 5 and MySOL E-Commerce by Cristian Darie and Mihai bucica, Apress, 2004, with hisappendix for Project Management added to the book Beginning ASP NET2.0 E-Commerce in C#2005 by Cristian Darie and Karli watson, Apress, 2005I would like to thank you for buying this book, my parents for everything they did for me, mygirlfriend who stood by me, the team at Globtel, which is like a second family for me and last,but not least a very good friend, the greatest technical author alive--Cristian DarieAbout the reviewerMizanur rahman is a Computer Science graduate from North South University, Bangladesh. Hehas 7 years of programming experience and vast knowledge on open-source technologies. He hasmore than 5 years of experience on working with PhP and PHP-related tools and technologiesCurrently he is working as a full time senior software engineer in a USA-based software companylocated in dhakaTable of contentsPrefaceChapter 1: Introduction to SmartyTemplating SystemsWhy Use a templating system?The smartness of smartSmarty Alternatives15567889A Rough Guide to the Software Design ProcessWorking in Teams: Layers and Separation of ConcernsSmarty-The Ultimate Templating System for PHP10Is Smarty Fast?Is Smarty SecureSmarty' s Main Features12Variable modifiers12Template Functions12Debugging13Plug-ins13Filters14Smarty Internals14Installing and Configuring Smarty15Step 1: Obtaining Smarty15Step 2: Configure PhP to Find the Smarty Libraries16On windows16On Linux16An Alternative to Step 2: Using Smarty without Having Full Access to theSystem16Step 3: Set Up Smarty for Your ApplicationStep 4: Verifying the InstallationSmarty Development Versions on CVsUpgrading a Smarty Site19Summary9Table of contentsChapter 2: Smarty site ArchitectureSeparation of Concerns22What does concern mean22A Problem-Solving perspective22Cross-cutting Concerns23Roles Involved in Building and Maintaining a Website23Starting a Smarty Project24Directory Structure24Securing our Smarty project25The data access layer25How it WorksThe Business logic layer27How it works28The Presentation layer29How it worksThe result31Summary32Smarty for DesignersChapter 3: What Designers Need to Know33Development Team problems: Common Scenarios33Roles of a Template Designer and a programmer34Definitions and Concepts for Designers35Concept of Reusability and Components36Splitting into Components38How to design T able-less layouts?41Handy Built-in Tags43Choosing an Editor for Template design44Collaborating with programmers46Summary47Chapter 4: Creating a Template9Design Concepts from htMl to TPL49Introduction to Smarty Variables52Starting Templates53Non-associative Array54Associative Array54
用户评论