Phalcon视图控制器无法控制视图

时间:2016-11-06 13:38:49

标签: php view phalcon volt

我正在为一个在线系统编写一个管理员网站ui,我设法使用,

将一个网址挂载到该视图
$app->get(
        "/main/index",
        function () use ($app){
            //no echo here
            $app["view"]->render(
                "main","index"
            );
        }
   );

我的主控制器就像,

<?php

class MainController extends ControllerBase
{

    public function initialize()
    {
        $this->tag->setTitle('Home Page');

        $this->view->setTemplateAfter('nav');
    }

    public function indexAction()
    {

    }
}

我的视图结构就像,

views
--layouts
----index.volt
----nav.volt
--main
----index.volt
--index.volt

我的问题是无论我如何更改MainController代码,它都不会影响渲染视图main,index上的任何内容。所以我想知道这里有什么问题?

1 个答案:

答案 0 :(得分:0)

render的第一个参数适用于您的视图模板,第二个参数适用于您的视图参数。

$app->get(
    "/main/index",
      function () use ($app) {
          $app["view"]->render(
              "main/index"
          );
      }
);

只需将"main","index"更改为"main/index"即可呈现您的观点。