View template not load

Hey dudes!

why i can't load template room.v ?

init View:

$di->set("view", function () {

    $view = new Phalcon\Mvc\View();
    $view->setViewsDir("../app/views/");
    $view->registerEngines([
        '.v' => function ($view, $di) {
            $volt = new Phalcon\Mvc\View\Engine\Volt($view, $di);
            $volt->setOptions([
                'compiledPath' => '../app/cache/',
                'compileAlways' => true,
                'compiledSeparator' => '__',
            ]);
            return $volt;
        }
    ]);

    return $view;
});

RoomsController.php:

...
public function showAction() {

        $this->view->roomName = $this->dispatcher->getParam('name');
        $this->view->pick('room');

    }
...

Just empty screen. No errors, no except-s.



64.2k

use absolute paths to be 100% sure path is correct ( ex: /var/www/mywebsite/app/views/ )

dont foget you always need

echo $this->getContent();

also you could be having some syntax errors/ or jsut errors, so make sure error reporting is on and you see the errors.

There are no errors, I checked this by creating specially errors. There is something else. For some reason, a completely different template is shown.

Look at this yourself: https://drive.google.com/file/d/0BwUG0P3DZeLgM2FlOHpWaHRaeDg/view?usp=sharing

I was helped by:

$view->setRenderLevel(View::LEVEL_LAYOUT);

But I'm not sure that this is the right decision. I await from you confirmation of my actions.



64.2k
edited May '17

you need to check those examples how to create shared layout app

https://github.com/phalcon/vokuro
https://github.com/phalcon/invo
https://github.com/phalcon/mvc


3.0k

Hello

have you try wth this option ?

$application->useImplicitView(false);

phil, yes, but it no effect for me



3.0k
edited Jun '17

in the documentation, a single name indicates the (controller) folder and by defaut the action name is used for the file name

can you create a folder 'common' in the folder views and move templates in it

public function showAction() {

        $this->view->roomName = $this->dispatcher->getParam('name');
        $this->view->pick('common/room');

    }
...