PHP N-tier: Building Presentation GUITag: n-tier, multi-tier, application architecture, application design, presentation, GUI Category: PHP Applicationpost: 15 Mar 2008 read: 146 PHP N-Tier Strategy Step By Step Tutorial - Part 7: We have grabbed data from server at presentation logic. And we tie data to html at previous post. It will give us more flexible if we you template system. So, we can change any layout without change all. for this job, we use smarty template. Exactly, what is smarty template? I rewrite from their readme: Smarty is a template engine for PHP. Many other template engines for PHP provide basic variable substitution and dynamic block functionality. Smarty takes a step further to be a "smart" template engine, adding features such as configuration files, template functions, and variable modifiers, and making all of this functionality as easy as possible to use for both programmers and template designers. First, please download smarty template at smarty.php.net. Extract compressed file to www/test/ntier. You will get folder named like "smarty-2.6.xx". Rename, for simply, become: "smarty". Then, create folders named "templates" and "templates_c" within www/test/ntier. Open again your client_book.php, rewrite with this code:
Now, you can see. Your code be more clean. No html tag over there. All html tag will be place at template. Create a file named "template.tpl" within www/test/ntier/templates. Then enter following code:
About smarty code, we will talk later. Congrat! you have understand how to build 5-tier use php. You can expand this tutorial as you need. |
| | Give Your Opinion | Recommend |
|

