Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How to set routing for dynamic GET Parameters

Hi Guys,

I am using Phalcon Paginator. Instead of

/products/list/?page=1

i would like to have

/products/list/1

How do i do this using routing? This is what i come of with, but does not work.

    $router->add('/products/list/:params', array(
    'controller' => 'products',
    'action'     => 'list',
    "params"     => $_GET['page']
));

Advice appreciated!



4.0k
Accepted
answer

Try:

$router->add('/products/list/{page:[0-9]+}', array(
    'controller' => 'products',
    'action'     => 'list'
));
class ProductsControler ...
{
    public function listAction($page = null)
    {

    }
}