Route globbing

Hi,

is there equivalent of this:

  
    map.connect '*path', :controller => 'content', :action => 'index'
  

in Picora?

Posted September 2nd, 2007 at 5:46am by vlado

Hi,

What should do this routing line ? I don't knows RoR so if you explain what result you hope, I could help you to find the right code line.

Posted September 2nd, 2007 at 5:52am by SuperDevy

I'm trying to do something like this

  
    PicoraDispatcher::addRoute('/*:id', array('Pages', 'show'));
  

It means that any url should call 'show' method of 'Pages' controller with url as argument.

  Visiting /about/ would call PagesController::show('about')
  Visiting /about/contact would call PagesController::show('about/contact'),
  Visiting /topsection/subsection/xyz would call PagesController::show('topsection/subsection/xyz')

Posted September 2nd, 2007 at 6:54am by vlado

Why not to write


PicoraDispatcher::addRoute('/', array('Pages', 'show'));
PicoraDispatcher::addRoute('/:topsection/:subsection/:artice', array('Pages', 'show'));

And as i can see, parameters are not passed to the controller method directly, but accessible via

Controller->params['topsection']
etc...

Posted September 2nd, 2007 at 7:08am by Chooh

Because number of "sections" is variable.

Posted September 2nd, 2007 at 7:27am by vlado

Hi,

The goal of the dispatcher if to simplify edition dispatch between URI and controllers. Using only one controller with one function is the same that ignore this functionality witch is the purpose of Picora. If you don't want to use this, you should use an other framework.

In the URI, you can use every common characters except "/". So you could delimit subsections with a simple comma !


PicoraDispatcher::addRoute('/:sections/:article', array('Pages', 'show')); 

And call it as this :


$this->url(array('Pages', 'show'), array(
    'sections' => implode(',', array('topsection','subsection'),
    'article'  => $article['id'],
));

And in the controller :


class Pages extends PicoraController {
    function show() {
        $sections = explode(',', $this->params['sections']);
        $article  = $this->params['article']
        // and the next ...
    }
}

Posted September 5th, 2007 at 7:07am by SuperDevy

Thanks SuperDevy!

Posted September 7th, 2007 at 6:43am by vlado

Anyone hacked/patched picora to have it enabled?

I also really really need :


PicoraDispatcher::addRoute('/page/*', array('Pages', 'show'));

To have unlimited arguments after /page/, like /page/2/DESC/date or /page/home-page

Posted January 25th, 2008 at 1:46pm by graaf

Anyone hacked/patched picora to have it enabled?

I also really really need :


PicoraDispatcher::addRoute('/page/*', array('Pages', 'show'));

To have unlimited arguments after /page/, like /page/2/DESC/date or /page/home-page

Posted January 25th, 2008 at 1:47pm by graaf

Login or Register to Post