2016-01-13 38 views
0

我試圖創建一個左側菜單欄。我曾經在我的佈局下面的代碼文件Templates/Layout/admin.ctpCakePHP 3.x邊欄不顯示任何內容

// Create the sidebar block. 
    $this->start('sidebar'); 
    echo $this->fetch('sidebar'); 
    echo $this->element('sidebar/left_menu'); 
    $this->end(); 

但側邊欄沒有在頁面顯示。左側菜單邊欄文件位於Templates/Element/Sidebar/left_menu.ctp

任何幫助將不勝感激。

+0

請編輯您的問題的格式化結束後 - 截至目前也很難看。最好避免'提前致謝!因爲它不添加任何有用的信息,只會增加噪音。 – Olga

+0

你的' fetch('sidebar')?>'? –

+0

我編輯了這個問題。 @Inigo弗洛雷斯我已將它添加到我的腳本中。還是行不通。 – Babitha

回答

1

有兩件事情我可以指出:

  • 爲模板的默認目錄是的src /模板,而不是模板
  • 當你開始塊,取(「側邊欄」 )將返回空。嘗試把它塊

    // Create the sidebar block 
    $this->start('sidebar'); 
    echo $this->element('sidebar/left_menu'); 
    $this->end(); 
    
    // Display the sidebar 
    $this->fetch('sidebar'); 
    
+0

嘿它的工作。謝謝道格拉斯。 '模板'是一個錯字。我嘗試把$ this-> fetch('sidebar');在塊的結尾。 – Babitha