Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

PHPTAL with CakePHP

9,623 views

Published on

第一回デザイナー向けCakePHP勉強会のLT発表資料です。PHPTALの概要、CakePHPでの利用方法について紹介します。

Published in: Technology, News & Politics
  • Be the first to comment

PHPTAL with CakePHP

  1. 1. PHPTAL with CakePHP July 2011 CakePHP
  2. 2. About Me• WEB Developer / PHP / CakePHP / HTML / CSS / jQuery / MySQL / iPhone / / / / / / / / no more• BLOG: http://php-tips.com/• TWITTER: @nojimage
  3. 3. Template Engine
  4. 4. Template Engine• HTML• Smarty, Twig, PHP, PHPTAL, etc...
  5. 5. Data Template Template Engine HTML, RSS Feed, etc...
  6. 6. PHPTAL
  7. 7. TAL• XHTML(XML)• http://wiki.zope.org/ZPT/TAL
  8. 8. Templae Attribute Language• XHTML(XML)• http://wiki.zope.org/ZPT/TAL
  9. 9. PHPTAL• Zope TAL PHP• http://phptal.org/• http://phptal.org/manual/ja/
  10. 10. code
  11. 11. Data
  12. 12. $people = array( array( ‘name’ => ‘Taro Yamada’, ‘phone’ => ‘090-0000-0000’ ), array( ‘name’ => ‘Hisateru Tanaka’, ‘phone’ => ’06-XXXX-XXXX’ ), // ...);
  13. 13. HTML
  14. 14. <table> <tr> <th>Name</th> <th>Phone</th> </tr> <tr> <td>persons name</td> <td>persons phone</td> </tr> <tr> <td>sample name</td> <td>sample phone</td> </tr></table>
  15. 15. <table> <tr> <th>Name</th> <th>Phone</th> </tr> <tr> <td>persons name</td> <td>persons phone</td> </tr> <tr> <td>sample name</td> <td>sample phone</td> </tr></table>
  16. 16. PHP
  17. 17. <table> <tr> <th>Name</th> <th>Phone</th> </tr> <?php foreach ($people as $person) : ?> <tr> <td><?php echo $person[name]; ?></td> <td><?php echo $person[phone]; ?></td> </tr> <?php endforeach; ?></table>
  18. 18. Smarty is not smart...
  19. 19. <table> <tr> <th>Name</th> <th>Phone</th> </tr> {foreach from=$people item=person} <tr> <td>{$person.name}</td> <td>{$person.phone}</td> </tr> {/foreach}</table>
  20. 20. PHPTAL
  21. 21. <table> <tr> <th>Name</th> <th>Phone</th> </tr> <tr tal:repeat="person people"> <td tal:content="person/name">personsname</td> <td tal:content="person/phone">personsphone</td> </tr> <tr tal:replace=""> <td>sample name</td> <td>sample phone</td> </tr></table>
  22. 22. <table> <tr> <th>Name</th> <th>Phone</th> </tr> <tr tal:repeat="person people"> <td tal:content="person/name">persons HTMLname</td> <td tal:content="person/phone">personsphone</td> </tr> <tr tal:replace=""> <td>sample name</td> <td>sample phone</td> </tr></table>
  23. 23. in Browser
  24. 24. in Browser
  25. 25. in Browser
  26. 26. in BrowserHTML
  27. 27. HTML
  28. 28. PHPTAL• 1. tal:define 7. tal:attributes 2. tal:condition 8. tal:on-error 3. tal:repeat 9. metal:define-macro 4. tal:omit-tag 10. metal:use-macro 5. tal:replace 11. metal:define-slot 6. tal:content 12. metal:fill-slot
  29. 29. PHPTAL is Smart!
  30. 30. PHPTAL
  31. 31. PHPTAL withCakePHP
  32. 32. CakePHP-TALTAL plugin
  33. 33. https://github.com/nojimage/ CakePHP-TALTAL
  34. 34. Feature• html, xhtml, zpt PHPTAL• ctp PHP OK•
  35. 35. Feature• url, fullurl• cake:helper
  36. 36. Installation• git clone or download• set to plugins/taltal• write to AppControllerclass AppController extends Controller { // ...(snip) public $view = Taltal.Phptal; // ...(snip)}
  37. 37. Let’s Try PHPTAL!! PHPTAL
  38. 38. CakePHP-TALTAL• https://github.com/nojimage/CakePHP-TALTAL• since 2011/06/01• version 0.3.1

×