1
正如前面我的問題所述,我是ATK4的新手,目前我正在學習,因此可能會出現更多問題。現在到我的問題。獲取視圖以自動使用正確的區域
我已經在我的模板shared.html
創建區域「Sidebar
」,加入這樣的觀點吧:
class Frontend extends ApiFrontend {
function init(){
parent::init();
/*
Other stuff here
*/
$this->addLayout('Sidebar');
}
function layout_Sidebar() {
$this->add('View_Menu', null, 'Sidebar');
}
}
然後我創建這樣的觀點:
class View_Menu extends AbstractView {
function init(){
parent::init();
$this->add('HtmlElement')
->setElement('a')
->setAttr('href', 'testurl')
->set('Link');
}
}
這給我以下錯誤:
Spot is not found in owner's template
Additional information:
spot: Content
提供添加樂趣ction與$this->template->top_tag
作爲第三個參數來解決這個問題:
$this->add('HtmlElement', null, $this->template->top_tag)
->setElement('a')
->setAttr('href', 'testurl')
->set('Link');
...但我真的將它添加到視圖中的每一個加()調用?這看起來不正確,我確信它不是!
嗯,也許它不是我應該使用的視圖,也許我應該創建它作爲HtmlElement的擴展。 – Bazze 2012-08-02 17:05:14