Monday, August 30, 2010

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

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: