0
我有几个前端模块,它有自己的边栏菜单链接。我想创建一个类模块的操作这些链接:在Symfony 1.4中创建动态边栏部分的最佳方法
public function preExecute()
{
$items['plan/new'] = 'Create Plan';
$items['plan/index'] = 'Plans Listing';
$this->getResponse()->setSlot('sidebar', $items);
}
插槽文件的sidebar.php
#apps/frontend/templates/sidebar.php
<?php slot('sidebar') ?>
<ul>
<?php foreach($items as $url => $title) : ?>
<li><?php echo link_to($url, $title) ?></li>
<?php endforeach ?>
</ul>
<?php end_slot() ?>
layout.php中:
<?php if (has_slot('sidebar')): ?>
<div id="sidebar"><?php include_slot('sidebar') ?></div>
<?php endif ?>
,但我的输出为阵,怎么能我渲染我的插槽?
如果您使用主视图(layout.php):$ this-> sidebar_menu = $ items;只是不起作用($ sidebar_menu总是在layout/php中未定义):/ – drupality 2011-12-18 14:06:05
看起来像你想要一个部分但有逻辑,使用一个组件,这正是他们的目的。 – Maerlyn 2011-12-18 17:22:19