まだ外でるとなつのにおいがするー

ちょういいにおい


すきすぎるなつ

しかし最近中国と仲悪いニュース多くておちる。。
昔住んでたガーデンホテルが、日本領事館あるからという理由で襲撃されてた

日本領事館も中国住んでる日本人もなんも悪くないのになー

はーぁ。。みんななかよくしようよ

smarty導入いっかいやったのだが。。
どうもうちの手順書がまずかったらしく毎回トラブルので
もっかいレッツトライ


まずfuelPHPをダウンロードしてきます

http://fuelphp.com/
今回はfuelphp-1.3

したらそのfuelphp-1.3ディレクトリをコピして、適当に名前変えて、
netBeansでひらきまーす

fuel/app/views/template.php
を適当に作成


以下はサンプル

--------------------
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><?= $title; ?></title>
<style type="text/css">
* { margin: 0; padding: 0; }
body { background-color: #EEE; font-family: sans-serif; font-size: 16px; line-height: 20px; margin: 40px; }
#wrapper { padding: 30px; background: #fff; color: #333; margin: 0 auto; width: 600px; }
a { color: #36428D; }
h1 { color: #000; font-size: 55px; padding: 0 0 25px; line-height: 1em; }
.intro { font-size: 22px; line-height: 30px; font-family: georgia, serif; color: #555; padding: 29px 0 20px; border-top: 1px solid #CCC; }
.notice { border: 1px solid #CCC; padding: 10px; background-color: #EEE; }
h2 { margin: 50px 0 15px; padding: 0 0 10px; font-size: 18px; border-bottom: 1px dashed #ccc; }
h2.first { margin: 10px 0 15px; }
p { margin: 0 0 15px; line-height: 22px;}
a { color: #666; }
pre { border-left: 1px solid #ddd; line-height:20px; margin:20px; padding-left:1em; font-size: 16px; }
pre, code { color:#137F80; font-family: Courier, monospace; }
ul { margin: 15px 30px; }
li { line-height: 24px;}
label { display: block; }
.footer { color: #777; font-size: 12px; margin: 40px 0 0 0; }
</style>
</head>
<body>
<div id="wrapper">
<h1><?= $title; ?></h1>
<? if (Session::get_flash('notice')): ?>
<div class="notice"><p><?= implode('</p><p>', (array)Session::get_flash('notice')); ?></div></p>
<? endif; ?>
<?= $content; ?>
<p class="footer">
ページ読み込みにかかったレンダリング時間 <exec_time>s 使ったメモリ <mem_usage>mb of memory.
</p>
</div>
</body>
</html>
--------------------次に、configにparserを追加


fuel/app/config/config.php
'always_load' => array(
'packages' => array(
//'orm',
'parser',
),
.....
)
からのー
public/index.php
の一番下の
array('{exec_time}', '{mem_usage}'),
を、パーサーがsmartyとかぶっちゃうので、
array('{exec_time}', '{mem_usage}'),
に変更しときます

いったん確認しよー


fuel/app/classes/controller/top.php
を新規作成して、
----------------
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
class Controller_Top extends Controller_Template
{
/**
* The basic welcome message
*
* @access public
* @return Response
*/
public function action_index()
{
$this->template->title='top';
$this->template->content = View::forge('top/index');
}
}
?>
----------------こんなかんじで


あとテンプレートもつくっとくぅ



fuel/app/views/top/index.php
中身はなんでもよいので、
とっぷー
とかかいとくヨロシ


これで、http:/~/top/index がみれればおけ

さぁsmartyいくよー



http://www.smarty.net/download
からsmartyをダウンロード

ディレクトリlibsだけを以下ディレクトリにいれま



ちなみに今回はSmarty-3.1.11だぁよ



fuel/app/vendor/Smarty
fuel/core/classes/controller/template.php
をコピーして以下を新規作成

fuel/core/classes/controller/smartytemplate.php
----------------------------
public $template = 'template';
⇒
public $template = 'template.tpl';
$this->template = \View::forge($this->template);
⇒
$this->template = \View_Smarty::forge($this->template);
----------------------------
に書き換え



fuel/core/bootstrap.php
に、smartyテンプレートクラスのパスを追記

'Fuel\\Core\\Controller_Smartytemplate' => COREPATH.'classes/controller/smartytemplate.php',
fuel/packages/parser/classes/view/smarty.php
デフォルトの拡張子を変更

// public $extension = 'smarty';
public $extension = 'tpl';
smartyのテンプレートつくりま


app/views/template.tpl
fuel/app/views/top/index.tpl
中身は違いわかるようにちょっと変えてすっと作って~

<?= $title; ?>
こーゆーのを
{$title}
こーなおして
topコントローラのextendを書き換えーの
class Controller_Top extends Controller_Smartytemplate
ビューの呼び出しのクラス書き換えーの
$this->template->content = View_Smarty::forge('top/index');
これでアクセスしてみれればOKなのです

いえい

まいち解釈に基づく『Maichidia』より抜粋
fuel/app/views/top/index.tpl
中身は違いわかるようにちょっと変えてすっと作って~


<?= $title; ?>
こーゆーのを
{$title}
こーなおして
topコントローラのextendを書き換えーの
class Controller_Top extends Controller_Smartytemplate
ビューの呼び出しのクラス書き換えーの
$this->template->content = View_Smarty::forge('top/index');
これでアクセスしてみれればOKなのです


いえい


まいち解釈に基づく『Maichidia』より抜粋
----------------------------------
DL ... だるい
すんっ ... 最近よくつかう効果音
すんっ ... 最近よくつかう効果音
----------------------------------
本日のひとこと

『ジャンケンすればいーのに』
参考URL:
http://press.nekoget.com/fuelphp_doc/general/controllers/template.html
