On Fri, Mar 20, 2009 at 11:58 PM, rod <[email protected]> wrote:
>
> Hi,
>
> I need help with routes.php, I've read the documentation and many
> blogs, articles but I still can't figure out how to do this:
>
> http://localhost/cat/categoryAlias/feed
>
> I have this which works fine:
>
> Router::connect(
>        '/cat/:category',
>        array('controller' => 'categories', 'action' => 'index'),
>        array('category' => '(.*)')
> );
>
> But then I'd like to have, for example: http://localhost/cat/Food/feed
> - and that would point to Food/index.rss, however it doesn't work,
> probably due to (.*) in the previous Router::connect.
>
You should tighten up the regexp a bit. Something like [-A-Za-z]+ or
[_A-Za-z]+ or thereabouts. It'll obviously depend on whatever rules
you have for creating your :category (slug)

Router::connect(
        '/cat/:category',
        array('controller' => 'categories', 'action' => 'index'),
        array(
                'category' => '[-_A-Za-z]+',
                'pass' => array('category')
        )
);

Router::connect(
        '/cat/:category/feed',
        array(
                'controller' => 'categories',
                'action' => 'index',
                'ext' => 'rss'
        ),
        array(
                'category' => '[-_A-Za-z]+',
                'pass' => array('category')
        )
);

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to