0
在主頁/ basepage上在Phalcon中切換登錄界面和註銷界面的好習慣?phalcon好的練習在登錄界面和登出界面之間切換
我可以做一個if-else語句從baseref/url頁面中的接口切換,但我不認爲這是一個很好的做法。
任何幫助是偉大的!
在主頁/ basepage上在Phalcon中切換登錄界面和註銷界面的好習慣?phalcon好的練習在登錄界面和登出界面之間切換
我可以做一個if-else語句從baseref/url頁面中的接口切換,但我不認爲這是一個很好的做法。
任何幫助是偉大的!
的爾康論壇使用你所提到的方法:https://github.com/phalcon/forum/blob/master/app/views/partials/top-menu.volt
更好的解決方案是使用佈局用條件
你的前端控制器可以從BaseFrontendController繼承,並選擇在自己的初始化佈局:
class BaseFrontendController extends BaseController {
public function initialize()
{
parent::initialize()
if ($this->authenticated) {
$this->view->setTemplateBefore('frontend-authenticated');
} else {
$this->view->setTemplateBefore('frontend-guest');
}
}
然後就延長從任何控制器BaseFrontendController你在前面有:
class IndexController extends BaseFrontendController {
public function initialize()
{
parent::initialize()
}
}
佈局文件通常很短,只是有一些包括。在這裏閱讀更多關於它們的信息:
http://docs.phalconphp.com/en/latest/reference/views.html#hierarchical-rendering