0
我掙扎上視圖和控制器約爾康細節缺乏文檔問題,如何在渲染特定視圖時插入佈局伏特?
我在做什麼的index.php中是什麼樣子,
$viewCollections = new MicroCollection() ;
$viewCollections->setHandler('BackenduiController',true) ;
$viewCollections->get('/main/index', 'index');
$app->mount($viewCollections) ;
在我的控制器,
<?php
use Phalcon\Mvc\View;
class BackenduiController extends ControllerBase
{
public function initialize()
{
}
public function index()
{
$this->tag->setTitle('A | B');
$this->view->setTemplateAfter('nav') ;
$this->view->render(
"main","index"
);
}
}
我的觀點伏文件的結構非常像,
意見
--layouts
----index.volt
----nav.volt
--main
----index.volt
--index.volt
nav.volt只是一個html代碼的導航欄片段,我的目的是在主/索引頁面中插入導航條形碼,但是如果我使用setTemplateAfter,結果頁面只是導航片段代碼,根本不顯示索引頁面。那麼,我應該如何安排代碼來使控制器呈現正確的頁面?
你加載你的觀點在'nav.volt'模板的內容。通過使用'{{content}}'? – Timothy
@蒂莫西,謝謝,是的,在nav.volt中,行之間有{{content()}}。 –