私はzend フレームワーク 1を使用しています。
別のファイル内に phtml ファイルを含め、最初のファイルにパラメーターを送信する必要があります。
元:
私はindexController.phpを持っています
そして$numberOfItem
、コントローラー内で定義しました
index.phtml 内にmenu.phtmlをレンダリング (インクルード) し、それに変数を送信する必要があります$numberOfItem
ありがとう
私はzend フレームワーク 1を使用しています。
別のファイル内に phtml ファイルを含め、最初のファイルにパラメーターを送信する必要があります。
元:
私はindexController.phpを持っています
そして$numberOfItem
、コントローラー内で定義しました
index.phtml 内にmenu.phtmlをレンダリング (インクルード) し、それに変数を送信する必要があります$numberOfItem
ありがとう
zend partialを使用してそれを行うことができます
あなたのindex.phtmlで
echo $this->partial('yourfolder/menu.phtml', array('numberOfItem' => $numberOfItem));
menu.phtmlでは、次を使用して変数の印刷を読み取ることができます
$this->numberOfItem
そのZend パーシャル。
IndexController では、通常どおり numberOfItem 値を対応するビューに渡します。
$this->view->numberOfItem = $numberOfItem;
次に、 index.phtml で:
echo $this->partial('viewfolder/menu.phtml', array('numberOfItem' => $this->numberOfItem));
menu.phtml で:
echo $this->numberOfItem;
パーシャルのパスのビュー フォルダーは、「ビュー/スクリプト」からの相対フォルダーと同じになります。たとえば、index.phtml と menu.phtml の両方が同じフォルダー "application/views/scripts/index" にある場合でも、パーシャルへのパスをindex/menu.phtmlとして渡す必要があります。