Smarty - Template Engine
Agenda <ul><li>Why  I Use Smarty </li></ul><ul><li>Model </li></ul><ul><li>Start Using Smarty </li></ul><ul><li>… . </li><...
<ul><li>Maintainability </li></ul><ul><li>Separate Design from Code </li></ul><ul><li>Keep your Branding & Design Clean </...
Model <ul><li>Have a model in your head of how Smarty  works. </li></ul>
Start Using Smarty  <ul><li>To get started, first download Smarty. Unzip the folder and upload the “libs” directory to you...
Welcome <!--{$name}--> to Smarty <script language=&quot;javascript&quot;> var foo = <!--{$foo}-->; function dosomething() ...
<?php $smarty = new  Smarty(); $smarty->assign('firstname', 'Doug'); $smarty->assign('lastname', 'Evans'); $smarty->assig...
<? php $smarty->assign('cust_ids', array(56,92,13)); $smarty->assign('cust_names', array(                ...
<select name=&quot;customer_id&quot; size=&quot;{$cust_names|@count}&quot;> {html_options values=$cust_ids output=$cust_na...
Thank you
Upcoming SlideShare
Loading in …5
×

How to Use PHP Smarty Template

5,396 views

Published on

PHP Smarty Template training material to know more information

Published in: Technology, Business
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,396
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
1
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

How to Use PHP Smarty Template

  1. 1. Smarty - Template Engine
  2. 2. Agenda <ul><li>Why I Use Smarty </li></ul><ul><li>Model </li></ul><ul><li>Start Using Smarty </li></ul><ul><li>… . </li></ul><ul><li>… </li></ul><ul><li>… </li></ul><ul><li>Conclusion </li></ul>
  3. 3. <ul><li>Maintainability </li></ul><ul><li>Separate Design from Code </li></ul><ul><li>Keep your Branding & Design Clean </li></ul><ul><li>Make your website loading snappy </li></ul><ul><li>Better Security </li></ul><ul><li>Speedup Front End Development </li></ul><ul><li>Manage Complicated user permissions and Targeted Logic </li></ul><ul><li>Change or Redesign on the Fly </li></ul><ul><li>Custom Smarty Functions </li></ul>Why I use Smarty
  4. 4. Model <ul><li>Have a model in your head of how Smarty works. </li></ul>
  5. 5. Start Using Smarty <ul><li>To get started, first download Smarty. Unzip the folder and upload the “libs” directory to your web server. Rename the “libs” folder to “Smarty” or something similar; this contains your Smarty classes. </li></ul><ul><li>Then create four folders called “templates”, “templates_c”, “configs” and “cache” in your webserver’s www root. Make sure “templates_c” is writable by the web server (CHMOD 700) because it will contain the cached files which the Smarty engine creates. If you want, add the smarty folder to your PHP include_path, so that whenever you write include ‘Smarty.class.php’, PHP will know where to include Smarty from. The SMARTY_DIR constant is the location of your Smarty classes. You don’t HAVE to set it if you just want to include the Smarty classes directly. </li></ul><ul><li>Reference: http://www.smarty.net/manual/en/installing.smarty.basic.php </li></ul>
  6. 6. Welcome <!--{$name}--> to Smarty <script language=&quot;javascript&quot;> var foo = <!--{$foo}-->; function dosomething() { alert(&quot;foo is &quot; + foo); } dosomething(); </script>
  7. 7. <?php $smarty = new  Smarty(); $smarty->assign('firstname', 'Doug'); $smarty->assign('lastname', 'Evans'); $smarty->assign('meetingPlace', 'New York'); $smarty->display('index.tpl'); ?>
  8. 8. <? php $smarty->assign('cust_ids', array(56,92,13)); $smarty->assign('cust_names', array(                               'Joe Schmoe',                               'Jane Johnson',                               'Charlie Brown')); $smarty->assign('customer_id', 92); ?>
  9. 9. <select name=&quot;customer_id&quot; size=&quot;{$cust_names|@count}&quot;> {html_options values=$cust_ids output=$cust_names selected=$customer_id} </select>
  10. 10. Thank you

×