Question

I made routing pattern as following:

$router->add('/album/view/{slug}-:int', array(
'controller' => 'album',
'action' => 'view',
'id' => 2,))->setName('album-view');

But it didnt work, so I changed the pattern to:

$router->add('/album/view/{slug}/:int', array(
'controller' => 'album',
'action' => 'view',
'id' => 2,))->setName('album-view');

And it worked perfectly!

So how to make routing pattern '/album/view/{slug}-:int' in Phalcon router? Thank for your help!

Was it helpful?

Solution

Documentation says:

/:int    /([0-9]+)    Matches an integer parameter

Meaning it actually expects /:int, not just :int. Just use named params with custom regex?

$router->add(
    '/album/view/{slug}-([0-9]+)',
    array(
        'controller' => 'album',
        'action'     => 'view',
        'id'         => 1, // ([0-9]+)
    )
);

I didn't test this, but must be along those lines.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top