2011-04-15 37 views
0

我樹立了新的contentkey用於顯示菜單在我site.like的右列是:

public function menuAction() 
{   
    $this->view->layout()->setContentKey('menu'); 

} 

這是佈局代碼:

<div class="center_col"><?php echo $this->layout()->content; ?></div> 
<div class="right_col"><?php echo $this->layout()->menu; ?></div> 

,但有一個概率!設置菜單contentKey後,每個動作結果顯示在右欄(內容不能工作!)

我有一個菜單動作插件,我認爲這是reasone!

這是我的插件:

class Places_Controller_Plugin_ActionSetup extends Zend_Controller_Plugin_Abstract 
{ 
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) 
{ 
    $front = Zend_Controller_Front::getInstance(); 

    if (!$front->hasPlugin('Zend_Controller_Plugin_ActionStack')) { 
      $actionStack = new Zend_Controller_Plugin_ActionStack(); 
      $front->registerPlugin($actionStack, 97); 
     } else { 
     $actionStack = $front->getPlugin('Zend_Controller_Plugin_ActionStack'); 
    } 

     $menuAction = clone($request); 
     $menuAction->setActionName('menu')->setControllerName('index'); 
     $actionStack->pushStack($menuAction); 

}} 

我NEAD中的所有頁面菜單操作調用,所以我用這個插件!

有什麼辦法解決我的問題?


答案與馬辛和SMka幫助:

public function menuAction() 
{   

    $this->view->placeholder("menu") 
        ->append($this->view->render("menu/menu.phtml")); 

} 
+1

您是否考慮使用佔位符視圖助手?在這種情況下,它可能比改變內容名稱更合適。 – Marcin 2011-04-16 02:52:54

+0

我檢查過,但它不能在行動方法中管理(或者我無法找到任何東西),我必須使用bootsrap文件來管理它!我更喜歡在操作方法 – afsane 2011-04-16 07:54:35

+1

afsane中管理菜單。您可以在操作中訪問佔位符視圖助手,例如$這個 - >查看 - >佔位符(「我的佔位符」)。 – Marcin 2011-04-16 08:03:28

回答

1
在你的菜單操作

只是渲染到指定的段

// Renders my/login.phtml to the 'form' segment of the 
// response object 
$this->render('login', 'form'); 

無需layout()->setContentKey,這種方法對於其他的事情