在Symfony 1.4中创建动态侧边栏部分的最佳方法

时间:2011-12-18 12:38:08

标签: view symfony1 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 ?>

但是我的输出是Array,我该如何渲染我的插槽?

0 个答案:

没有答案