我们都知道 $content_for_layout 现在在 cakephp 2.1 中已被弃用并更改为 $this->fetch('content');
无论我们将 fetch('content') 放在哪里,都将在其中查看布局标记的 View 内容。
我的问题是,例如我有一个 View navigation(),该 View 的内容将放置在 $this->fetch('nav_view') 上,而对于 View main_board() ,内容将放置在 $this 上->fetch('main_board'),
这两个提取将在同一布局上输出。这可能吗?
最佳答案
在你的 View /元素/助手中的某个地方:
$this->start('nav_view');
// render your 'nav_view' stuff here
echo $this->element('...');
$this->end();
渲染与内容相同:
// in layout
$this->fetch('nav_view');
显然,这现在已记录在食谱中的 Using view blocks 下.
关于php - 如何在 $this->fetch() cakephp 2.1 上指定值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10891864/