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

Problems in views

Hello.

I have a 2 question, when in enter the "/" in my address bar, the Controller Template load successfully but the chiled page not, but when i use view->pick("my_view_name") it,s okay, so what is a problem, when i enter the complete address containing module, controller and actio name, the views work fine ... but when i enter the "/" as address i have to use pick method of view object, here is my routes.

$router->add("/:module/:controller/:action/:params", array( "module" => 1, "controller" => 2, "action" => 3, "params" => 4 ));

$router->add("/", array( "module" => "public_zone", "controller" => "Guests", "action" => "index" ));

My another question is about setTemplateAfter and setTemplateBefore diffrences, what is their diffrences ?

Hi,
Did you usesetDefaultModule ?

$router = new Phalcon\Mvc\Router();

$router->setUriSource(\Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI);

$router->removeExtraSlashes(true);
$router->setDefaultModule('admin');
$router->setDefaultController('index');
$router->setDefaultAction('index');

setTemplateAfter, setTemplateBefore are additional layers you can use for your needs
setTemplateAfter is rendered after Controller View, and setTemplateBefore before Controller View

https://docs.phalcon.io/en/latest/reference/views.html#hierarchical-rendering https://docs.phalcon.io/en/latest/reference/views.html#control-rendering-levels