phptal with cakephp

45
PHPTAL with CakePHP July 2011 デザイナー向けCakePHP勉強会

Upload: takashi-nojima

Post on 19-May-2015

7.944 views

Category:

Technology


3 download

DESCRIPTION

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

TRANSCRIPT

Page 1: PHPTAL with CakePHP

PHPTAL with CakePHP

July 2011

デザイナー向けCakePHP勉強会

Page 2: PHPTAL with CakePHP

About Me

• WEB Developer / PHP / CakePHP / HTML / CSS / jQuery / MySQL / iPhone / 佐賀 / 福岡 / 島根 / 熊本 / プリン / キイロイトリ / ミッフィー / no more トマト

• BLOG: http://php-tips.com/

• TWITTER: @nojimage

名前: 野島 隆(のじま たかし)所属:イラスティックコンサルタンツ株式会社

Page 3: PHPTAL with CakePHP

Template Engine

Page 4: PHPTAL with CakePHP

Template Engine

•データとテンプレートを合成してHTMLなどを出力する

•Smarty, Twig, PHP, PHPTAL, etc...

Page 5: PHPTAL with CakePHP

Data Template

TemplateEngine

HTML,RSS Feed,

etc...

Page 6: PHPTAL with CakePHP

PHPTAL

Page 7: PHPTAL with CakePHP

TAL

•表示のためのロジックをXHTML(XML)の属性として記述する

•http://wiki.zope.org/ZPT/TAL

Page 8: PHPTAL with CakePHP

Templae Attribute Language

•表示のためのロジックをXHTML(XML)の属性として記述する

•http://wiki.zope.org/ZPT/TAL

Page 9: PHPTAL with CakePHP

PHPTAL

•ZopeのTALをPHPへ移植したもの

•公式http://phptal.org/

•日本語マニュアル

http://phptal.org/manual/ja/

Page 10: PHPTAL with CakePHP

code

Page 11: PHPTAL with CakePHP

氏名と電話番号の表

Page 12: PHPTAL with CakePHP

Data

Page 13: PHPTAL with CakePHP

$people = array( array( ‘name’ => ‘Taro Yamada’, ‘phone’ => ‘090-0000-0000’ ), array( ‘name’ => ‘Hisateru Tanaka’, ‘phone’ => ’06-XXXX-XXXX’ ), // ...);

Page 14: PHPTAL with CakePHP

HTML

Page 15: PHPTAL with CakePHP

<table> <tr> <th>Name</th> <th>Phone</th> </tr> <tr> <td>person's name</td> <td>person's phone</td> </tr> <tr> <td>sample name</td> <td>sample phone</td> </tr></table>

Page 16: PHPTAL with CakePHP

<table> <tr> <th>Name</th> <th>Phone</th> </tr> <tr> <td>person's name</td> <td>person's phone</td> </tr> <tr> <td>sample name</td> <td>sample phone</td> </tr></table>

この部分をデータの件数分繰り返して表示したい

Page 17: PHPTAL with CakePHP

PHP

Page 18: PHPTAL with CakePHP

<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>

Page 19: PHPTAL with CakePHP

Smarty

is not smart...

Page 20: PHPTAL with CakePHP

<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>

Page 21: PHPTAL with CakePHP

PHPTAL

Page 22: PHPTAL with CakePHP

<table> <tr> <th>Name</th> <th>Phone</th> </tr> <tr tal:repeat="person people"> <td tal:content="person/name">person's name</td> <td tal:content="person/phone">person's phone</td> </tr> <tr tal:replace=""> <td>sample name</td> <td>sample phone</td> </tr></table>

Page 23: PHPTAL with CakePHP

<table> <tr> <th>Name</th> <th>Phone</th> </tr> <tr tal:repeat="person people"> <td tal:content="person/name">person's name</td> <td tal:content="person/phone">person's phone</td> </tr> <tr tal:replace=""> <td>sample name</td> <td>sample phone</td> </tr></table>

HTMLの属性として記述

Page 24: PHPTAL with CakePHP

in Browser

Page 25: PHPTAL with CakePHP

in Browser

Page 26: PHPTAL with CakePHP

in Browser

Page 27: PHPTAL with CakePHP

in Browser

元のHTMLそのまま

Page 28: PHPTAL with CakePHP

表示のためのロジックを組み込んでも

HTMLを壊さない

Page 29: PHPTAL with CakePHP

ロジックを追加した後でもデザイナー側で

見た目の調整が可能

Page 30: PHPTAL with CakePHP

PHPTAL

•シンプルな構文1. tal:define2. tal:condition3. tal:repeat4. tal:omit-tag5. tal:replace6. tal:content

7. tal:attributes8. tal:on-error9. metal:define-macro10. metal:use-macro11. metal:define-slot12. metal:fill-slot

Page 31: PHPTAL with CakePHP

PHPTAL is Smart!

Page 32: PHPTAL with CakePHP

つまり

Page 33: PHPTAL with CakePHP

PHPTALはモテる!

Page 34: PHPTAL with CakePHP

かも。

Page 35: PHPTAL with CakePHP
Page 36: PHPTAL with CakePHP

PHPTALwith

CakePHP

Page 37: PHPTAL with CakePHP

CakePHP-TALTALplugin

Page 39: PHPTAL with CakePHP

Feature

•拡張子html, xhtml, zptのテンプレートをPHPTALで解釈!!

•通常のctpは、生PHPのテンプレートとして利用OK!

•テーマ機能対応!

Page 40: PHPTAL with CakePHP

Feature

•url, fullurlモディファイアの追加•cake:helper属性の追加

Page 41: PHPTAL with CakePHP

Installation

•git clone or download

•set to plugins/taltal

•write to AppControllerclass AppController extends Controller { // ...(snip)

public $view = 'Taltal.Phptal';

// ...(snip)}

Page 42: PHPTAL with CakePHP

Let’s Try PHPTAL!!次のプロジェクトの

テンプレートエンジンはPHPTALで♡

Page 43: PHPTAL with CakePHP

CakePHP-TALTAL

• https://github.com/nojimage/CakePHP-TALTAL

•since 2011/06/01

•version 0.3.1

Page 44: PHPTAL with CakePHP

人柱募集!!

Page 45: PHPTAL with CakePHP

ご静聴ありがとうございました