CakePHP 3.x 边栏没有显示任何内容
CakePHP 3.x Sidebar is not showing any content
我正在尝试创建左侧菜单栏。我在布局文件中使用了以下代码 Templates/Layout/admin.ctp
// Create the sidebar block.
$this->start('sidebar');
echo $this->fetch('sidebar');
echo $this->element('sidebar/left_menu');
$this->end();
但是侧边栏没有显示在页面中。左侧菜单边栏文件位于 Templates/Element/Sidebar/left_menu.ctp
我们将不胜感激。
我可以指出两点:
- 模板的默认目录是 src/Template 而不是 Templates
当您启动块时,fetch('sidebar') 将 return 清空。尝试把它放在块的末尾之后
// Create the sidebar block
$this->start('sidebar');
echo $this->element('sidebar/left_menu');
$this->end();
// Display the sidebar
$this->fetch('sidebar');
我正在尝试创建左侧菜单栏。我在布局文件中使用了以下代码 Templates/Layout/admin.ctp
// Create the sidebar block.
$this->start('sidebar');
echo $this->fetch('sidebar');
echo $this->element('sidebar/left_menu');
$this->end();
但是侧边栏没有显示在页面中。左侧菜单边栏文件位于 Templates/Element/Sidebar/left_menu.ctp
我们将不胜感激。
我可以指出两点:
- 模板的默认目录是 src/Template 而不是 Templates
当您启动块时,fetch('sidebar') 将 return 清空。尝试把它放在块的末尾之后
// Create the sidebar block $this->start('sidebar'); echo $this->element('sidebar/left_menu'); $this->end(); // Display the sidebar $this->fetch('sidebar');