Phalcon view controller is not controlling the view

I'm programming an admin web ui for a online system, I managed to mount a url to the view using,

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

And my Main controller is like,

<?php

class MainController extends ControllerBase
{

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

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

    public function indexAction()
    {

    }
}

My view structure is like,

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

My problem is no matter how I change the MainController code, it doesn't affect anything on the rendered view main,index. So I wish to know what's wrong here?

All I wanted is just for all my pages, there can be a nav bar showing, the nav bar code should be in nav.volt file. However this is not working.



30.7k

Hi,

I think that you are trying to use MVC full stack framework in the context of a micro app.

If you want to use controllers with micro app have a look here: https://docs.phalconphp.com/en/latest/reference/micro.html#using-controllers-as-handlers