0

您好,我正在尝试在我的默认布局中获取一个元素,但它没有显示任何内容,因为我遵循了有关显示块的 cakephp 文档,我还没有发现我的错误。

我的 MenusController.php

<?php

class MenusController extends AppController{

    public function beforeFilter(){

        parent::beforeFilter();
        $this->Auth->allow();

    }

    public function get_menu(){

      if ($this->Auth->user()['role'] == 'admin'){
        $this->set('dashboard_menu',$this->dashboard_menu_admin());
      }
      else
        $this->set('dashboard_menu',$this->dashboard_menu_user());

    }

    private function dashboard_menu_admin(){

        $dashBoardMenu = array(
                            array(
                                'elementName' => 'Usuarios',
                                'iconName'=> 'user',
                                'action' => 'users'
                               ),
                            array('elementName' => 'Personal',
                                  'iconName' => 'user',
                                  'action'=>'personal'
                                  ),
                            array('elementName' => 'Resumen Semanal',
                                  'iconName' => 'edit',
                                  'action' => 'resumen'
                                  ),
                            array('elementName' => 'Estadisticas',
                                  'iconName' => 'signal',
                                  'action' => '#'
                                  ),
                            array('elementName' => 'Tareas',
                                  'iconName' => 'check',
                                  'action' => '#'
                                  ),
                            array('elementName' => 'Calendario',
                                  'iconName' => 'calendar',
                                  'action' => '#'),
                            array('elementName' => 'Nube',
                                  'iconName' => 'cloud',
                                  'action'=> '#')
                   );

        return $dashBoardMenu;

    }

    private function dashboard_menu_user(){

        $dashBoardMenu = array(
                            array(
                                'elementName' => 'Usuarios',
                                'iconName'=> 'user',
                                'action' => 'users'
                               ),
                            array('elementName' => 'Resumen Semanal',
                                  'iconName' => 'edit',
                                  'action' => 'resumen'
                                  ),
                            array('elementName' => 'Estadisticas',
                                  'iconName' => 'signal',
                                  'action' => '#'
                                  ),
                            array('elementName' => 'Tareas',
                                  'iconName' => 'check',
                                  'action' => '#'
                                  ),
                            array('elementName' => 'Calendario',
                                  'iconName' => 'calendar',
                                  'action' => '#'),
                            array('elementName' => 'Nube',
                                  'iconName' => 'cloud',
                                  'action'=> '#')
                   );

        return $dashBoardMenu;

    }

}

在视图/菜单/get_menu.ctp

<?php
$this->start('menu');
    echo $this->element('menu/dashboard_menu',array('menuItems' => $dashboard_menu));
$this->end();   

?>

部分视图/布局/default.ctp

    <div class="container-fluid" id="container">

        <div class="row-fluid"> 
            <?php if ($logged_in): ?>

              <?php  echo $this->fetch('menu'); //THiS IS NOT DISPLAYING ANYTHING  ?>

            <?php endif; ?>
            <div class="span9" id="content">
                <?php echo $this->Session->flash(); ?>
                <?php echo $this->Session->flash('auth'); ?>
                <?php echo $this->fetch('content'); ?>

            </div>

        </div>

    </div>

我正在尝试在开始和结束方法之间打印回声“某物”,但我什么也没得到。我认为它不吸引人,但我不知道为什么

有人可以帮助我。谢谢。

4

0 回答 0