Zend Frameworkに問題があります。私はデータベースからいくつかのデータを要求するプラグインを作成しました。私layout.phtmlでプラグインのデータをZend Frameworkのpartialに渡すには?
<?php
class Blog_Plugin_Navigation extends Zend_Controller_Plugin_Abstract {
public function routeShutdown(Zend_Controller_Request_Abstract $request) {
$navigation = new Application_Model_NavigationMapper();
$view = Zend_Layout::getMvcInstance()->getView();
$view->navigation = $navigation->fetchAll();
}
}
私はこれを使用します。
<ul>
<?=$this->partialLoop('navigation-item.phtml', $this->navigation)?>
</ul>
私は私のデータベースから値を取得し、配列をプリントアウトしますprint_rを使用しますが、私は私のウェブサイトを訪問する場合、私はちょうどなし得ます値。ナビゲーション-item.phtmlは、次のようになります。
<li><a href="<?=$this->url?>"><?=$this->text?></a></li>
私はこれを取得:私のミスはどこ
<li><a href=""></a></li>
のですか?誰かが私を助けることができれば本当にいいですね。 :) 前もって感謝します。
<?=$this->partialLoop('navigation-item.phtml', $this->navigation)->setObjectKey('model')?>
と
で
を置き換えます'var_dump($ navigation-> fetchAll())'を実行し、部分テンプレートの中の 'var_dump($ this-> url、$ this-> text)'のために何を得ますか? – drew010
'var_dump($ navigation-> fetchAll())'のために私は表示したい値と 'var_dump($ this-> url、$ this-> text)'の配列を取得します。 :/ – anisie
あなたの 'layout.phtml'スクリプトの' $ this-> navigation'にも 'NULL'があるのでしょうか?私は、変数がそこに割り当てられていると思うでしょう、多分それは何とかpartialLoopで失われる。あなたの値は '$ navigation'配列オブジェクトまたは配列内にありますか?あなたが '<?= $ this ['url']?>'と '<?= $ this ['text']?>'を試そうとするとどうなりますか? – drew010