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.

Phalcon Router same url

Is it posible to have same router with different controller and action?

example

    $router->add('/:params', array(
        'module' => 'frontend',
        'controller' => 'center',
        'action' => 'page',
        'params' => 1,
    ));

    $router->add('/:params', array(
        'module' => 'frontend',
        'controller' => 'page',
        'action' => 'view',
        'params' => 1,
    ));

It will use the first one it encounters when matching routes, so one of them will be discarded.

I can't imagine what practical use there would be for having 2 routes with the same pattern.

This is the case my client want same url for the page and center

example: https://mysite/center-slugs - this is for center https://mysite/page-slugs - this is for page..



1.4k
Accepted
answer
edited Aug '15

basicaly we did a dirty hack to make this happend thank you for the reply...

public function pageAction($slugs){

    if(page != null){
        execute page
    }
    else{
         //execute center
         $this->centerAction($slugs);
         //redirect view to center view
         $this->view->pagelayout = 'center';
         $this->view->pick("center/view");
    }

}

fucntion centerAction($slugs){
    //code for center call
}