Php/zend framework/smartyメモのソースを表示
←
Php/zend framework/smartyメモ
ナビゲーションに移動
検索に移動
あなたには「このページの編集」を行う権限がありません。理由は以下の通りです:
この操作は、次のグループに属する利用者のみが実行できます:
登録利用者
。
このページのソースの閲覧やコピーができます。
=テンプレートにSmartyを使用= http://framework.zend.com/manual/ja/zend.view.scripts.html からZend_View_Smartyクラスをコピーし、Custom_View_Smartyに変更し、Custom/View/Smarty.phpへ保存。 上記はsmarty3ではエラーとなるので、以下を使用 [[php/zend_framework/smarty3用]] [ショートカット] ==index.php(フロントコントローラー)に以下を記載== require_once dirname(__FILE__) . '/../library/Custom/View/Smarty.php'; require_once 'Zend/Controller/Action/Helper/ViewRenderer.php'; require_once 'Zend/Config/Ini.php'; $setting = new Zend_Config_Ini('../application/configs/smarty.ini', 'SmartySetting'); $view = new Custom_View_Smarty(null, $setting); $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); $viewRenderer->setView($view) ->setViewBasePathSpec("../application/views/templates") ->setViewScriptPathSpec(':controller/:action.:suffix') ->setViewScriptPathNoControllerSpec(':action.:suffix') ->setViewSuffix('tpl'); ==smarty.ini== [SmartySetting] compile_dir=../application/views/templates_c left_delimiter="{{<nowiki />" right_delimiter="}}" ==error.tplのサンプル== <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <<nowiki />html xmlns="http://www.w3.org/1999/xhtml"> <<nowiki />head> <<nowiki />meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <<nowiki />title>An error occurred</title> </head> <<nowiki />body> <<nowiki />h1>An error occurred</h1> <<nowiki />h2>{{<nowiki />$message|escape:html}}</h2> {{<nowiki />if 'development' == $smarty.const.APPLICATION_ENV}} <<nowiki />h3>Exception information:</h3> <<nowiki />p> <<nowiki />b>Message:</b> {{<nowiki />$exception->getMessage()}} </p> <<nowiki />p> <<nowiki />b>Class:</b> {{<nowiki />$exception|get_class}} </p> <<nowiki />p> <<nowiki />b>Code:</b> {{<nowiki />$exception->getCode()}} </p> <<nowiki />p> <<nowiki />b>File:</b> {{<nowiki />$exception->getFile()}}({{<nowiki />$exception->getLine()}}) </p> <<nowiki />h3>Stack trace:</h3> <<nowiki />pre>{{<nowiki />$exception->getTraceAsString()}} </pre> <<nowiki />h3>Request Parameters:</h3> <<nowiki />pre> {{<nowiki />foreach item=item key=key from=$request->getParams()}} {{<nowiki />$key}} => {{<nowiki />$item}} {{<nowiki />/foreach}}</pre> {{<nowiki />/if}} </body> </html> ==zend_applicationでmodulesを使用したときのサンプル== *bootstrap.phpへ追記 protected function _initSmarty() { require_once dirname(__FILE__) . '/../library/Custom/View/Smarty.php'; require_once 'Zend/Controller/Action/Helper/ViewRenderer.php'; require_once 'Zend/Config/Ini.php'; $request = new Zend_Controller_Request_Http(); // module名がうまく取得できなかったので、無理やり preg_match("!^/([\w]*)/!", $request->getRequestUri(), $matches); $module = $matches[1]; // ini追記モードで取得 $setting = new Zend_Config_Ini('../application/configs/smarty.ini', 'SmartySetting', true); $setting->compile_dir = '../application/modules/' . $module . '/views/templates_c'; $view = new Custom_View_Smarty(null, $setting); $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); $viewRenderer->setView($view) ->setViewBasePathSpec('../application/modules/' . $module . '/views/templates') ->setViewScriptPathSpec(':controller/:action.:suffix') ->setViewScriptPathNoControllerSpec(':action.:suffix') ->setViewSuffix('tpl'); } ==コントローラーからSmartyクラスを呼び出す== $smarty = $this->view->getEngine(); ==Fatal error: Smarty error: unable to write toエラーが出る場合== 以下表示が出て、compilesのdirに書き込みでない場合は、compilesの権限を777にしてみる。 Fatal error: Smarty error: unable to write to selinuxが有効になってる可能性があるので確認する $ getenforce Enforcing 有効(Enforcing)になってる場合は、一旦無効にしてみる。 $ sudo setenforce 0 [[Vps/kagoya]] [ショートカット]
Php/zend framework/smartyメモ
に戻る。
ナビゲーション メニュー
個人用ツール
ログイン
名前空間
ページ
議論
日本語
表示
閲覧
ソースを閲覧
履歴表示
その他
検索
案内
プログラムメモ
php
flutter
java
android
kotlin
ios
unity
unrealengine
javascript
mysql
sqlite
postgresql
oracle
mroonga
mongodb
flash
electron
cocos2dx
titanium
cpp
ruby
perl
python
accessメモ
rss
html
monaca
cordova
golang
blender
セキュリティ
テストツール
サーバメモ
linux
dotnet
apacheメモ
htaccessメモ
subversion
git
仮想サーバ
ansible
sendgrid
xampp
cacti
mecab
faces
flashpolicyd
fcs
jenkins
運用
デザインメモ
css
ユーザビリティ
ux
サービスメモ
twitter
facebook
instagram
mixi
セカンドライフ
通信ログ横取り
google
ustream
aws
gcp
plesk
azure
vps
AI
その他サービス
便利系メモ
SEO
モバイル
抽象変数名
DDD
クライアント
firefox
chrome
pgp
windows
mac
jmetar
Thunderbird
excel
libreoffice
vpnclient
doxygen
VisualStudioCode
fastlane
metaquest
cmsメモ
mediawiki
pukiwiki
wordpress
その他
資格
IT用語
pvを稼ぐ方法
将棋プログラム
その他
ログイン
ページ内
メインページ
最近の更新
人気のページ
問い合わせ
ツール
リンク元
関連ページの更新状況
ページ情報