We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Don't show main view.

Hi! I have module Game:

And two Controllers - IndexController.php, PlayController.php

Routing:


$router->add('/:module', array(
    'module' => 1,
    'controller' => 'index',
    'action' => 'index',
));

$router->add('/:module/:action', array(
    'module' => 1,
    'controller' => 'index',
    'action' => 2,
));

$router->add('/play/:params', array(
    'module' => 'game',
    'controller' => 'play',
    'action' => 'index',
    'params' => 1
));
```php

**Module.php**

```php
$di->set('view', function() {
            $view = new \Phalcon\Mvc\View();

            $view->setViewsDir(__DIR__ . '/views/');
            $view->setLayoutsDir('../../../templates/');
            $view->setPartialsDir('../../../templates/partials/');

            return $view;
        });
```php

--1-- /templates/index.phtml - the main view.

I open link:

www.site.loc/game/ - OK, all views rendered. [Module - Game, Controller - Index, Action - Index]
www.site.loc/play/1 - Show View only /views/play/index.phtml, but without main view --1--. [Module - Game, Controller - Play, Action - Index]

But if move /templates/index.phtml to /modules/game/views/index.phtml - OK

Why? How correct it?
edited Sep '14

Insert in PlayController.php:

public function initialize()
{
    $this->view->setTemplateAfter('index');
    parent::initialize();
}

But I still do not understand why two controllers in one module behave differently.