【问题标题】:Phalcon view controller is not controlling the viewPhalcon 视图控制器不控制视图
【发布时间】:2016-11-06 13:38:49
【问题描述】:

我正在为在线系统编写管理 web ui,我设法将 url 安装到视图中,

$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 上的任何内容。所以我想知道这里出了什么问题?

【问题讨论】:

    标签: php view phalcon volt


    【解决方案1】:

    render的第一个参数是你的视图模板,第二个是你的视图参数。

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

    只需将"main","index" 更改为"main/index",您的视图就会呈现。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-11
      • 1970-01-01
      • 1970-01-01
      • 2023-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多