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

Routing with url parameter

I have added this router:

$router->add('/admin/posts/{param}/{id:[0-9]+}', array('controller' => 'admin', 'action' => 'posts'));

But why is that, the url HAS to contain /admin/posts/show/9 Why is it that i can't make it work if it's /admin/posts/

I my controller i just say if param is not empty show view and so on :-)

Hope you understand :-)

Try this:

$router->add('/admin/posts/{param}[/]?{id:[0-9]*}', array('controller' => 'admin', 'action' => 'posts'));

That worked, thank you! :-)