0
layout.phtml代碼:在zendframework從數據庫下拉菜單2佈局
<ul class="dropdown-menu">
<li><a tabindex="-1" href="<?php echo $this->url('project') ?>">Java</a></li>
<li><a tabindex="-1" href="<?php echo $this->url('project') ?>">android</a></li>
<li><a tabindex="-1" href="<?php echo $this->url('project') ?>">Dot Net</a></li>
<li><a tabindex="-1" href="<?php echo $this->url('project') ?>">Zend Framework</a></li>
</ul>
,但我想轉換成循環這裏。
Module.php代碼:
class Module
{
public function onBootstrap(MvcEvent $e) {
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
// this is for session
$this->initSession(array(
'remember_me_seconds' => 180,
'use_cookies' => true,
'cookie_httponly' => true,
));
// this code is not working(to get the values from db for menu list)
$service = $this->getServiceLocator()->get('UserService');
$result = $service->getmenulist();
$this->layout()->myVariable = $result;
}
//other code
}
這是我的佈局當前菜單,但我想使下拉從數據庫列表。我不知道如何將值從module.php傳遞給佈局。任何人都可以幫助我解決這個問題。有沒有其他的方式來執行它。在module.php中,我試圖獲取菜單名稱列表並將其傳遞給佈局。
瞭解視圖助手和依賴注入) – Sam 2014-09-03 21:26:22