Tuesday, August 31, 2010

Re: Router::connect() not behaving as expected in 1.3?

Thanks for the example, DragonFlyEye and thanks for the feedback
Nikhil. I have finally come to terms with needing 2 statements. In
1.2 (even if it was incomplete) it worked with one statement. The
features of 1.3 are well worth specifying 2 routes.

Thanks again!

On Aug 31, 2:17 pm, DragonFlyEye <dragonflyey...@gmail.com> wrote:
> It's not so much wrong as incomplete. Any URL *beginning* with '/
> cooks/' will be handled in the above-quoted fashion. But if it begins
> *and ends* with '/cooks', without another routing statement, you'll
> get the error you're talking about. Have a look at the pre-defined
> routing for pages that's already in your routes.php file:
>
>         Router::connect('/pages', array('controller' => 'pages', 'action' =>
> 'index'));
>         Router::connect('/pages/*', array('controller' => 'pages', 'action'
> => 'display'));
>
> There are two statements - not one - that define how that set of
> subdirectories will be handled.
>
> On Aug 30, 6:20 pm, Nikhil <nikhilvijay...@gmail.com> wrote:
>
> > SacoDesign is right. its not working as expected (or the cook book is
> > wrong)
>
> > - - Here is the same from cookbook (http://book.cakephp.org/view/46/Routes-Configuration
> > )
>
> > "Another common use for the Router is to define an "alias" for a
> > controller. Let's say that instead of accessing our regular URL at /
> > users/someAction/5, we'd like to be able to access it by /cooks/
> > someAction/5. The following route easily takes care of that:
> > Plain Text View
>
> > Router::connect(
> >     '/cooks/:action/*', array('controller' => 'users', 'action' =>
> > 'index')
> > );
>
> > This is telling the Router that any url beginning with /cooks/ should
> > be sent to the users controller. "
>
> > It works fine except if there is no action specified that is the
> > situation in which cake should default to index() function
>
> > /cooks/action1 maps to users->action1()
> > /cooks/action2 maps to users->action2()
> > /cooks/index maps to users->index()
>
> > *BUT*
>
> > /cooks shows a CooksController missing error message
>
> > On Aug 25, 6:05 pm, SacoDesign <sign...@sacodesign.com> wrote:
>
> > > Hello,
>
> > > I'm upgrading my app from 1.2 to 1.3.  I have several custom routes
> > > setup like so:
> > > Router::connect('/blog/:action/*',
> > > array('controller'=>'news_articles', 'action'=>'index'));
>
> > > This works fine, except for when the url is only /blog/.  In that case
> > > I get a "cannot find blog controller" error.  Is this by design, or a
> > > bug?
>
> > > I can get it working by adding another route for:
>
> > > Router::connect('/blog', array('controller'=>'news_articles',
> > > 'action'=>'index'));
>
> > > but that seems wrong.
>
> > > Thanks,
>
> > > -Kevin Wentworth
>
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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

No comments: