2012-04-11 60 views
0

我讀過關於佔位符的這篇文章。以前,我在我的視圖腳本中包含了一堆文件。在時間變得複雜了,因爲我不得不考慮上下文,並且沒有一個很好的解決方案。zend佈局佔位符在哪裏走?

我猜這是佔位符進來的地方。我讀了zend article。我讀過的文章中沒有一篇關於我放置佔位符的位置。他們應該進入哪個文件夾?

原諒我,我仍然非常困惑與zend。

+0

看看我的答案在這裏http://stackoverflow.com/a/9264520/212940,看看它是否有幫助。我鏈接它,因爲你鏈接到的文章是關於視圖助手,而不是佔位符。 – vascowhite 2012-04-11 05:43:49

回答

1

基本上你會在控制器/視圖中的某處捕獲一個塊,然後你會在模板/佈局中顯示它。

我覺得這個Zend Doc example makes more sense

// before the view is displayed 
// you can use other methods to render the templates into placeholder for later use 
<?php $this->placeholder('foo')->set("Some text for later") ?> 

// most like somewhere in the view 
<?php 
    echo $this->placeholder('foo'); 
    // outputs "Some text for later" 
?> 
or 
<?= $this->placeholder('sidebar') ?>