Tuesday, December 30, 2008

Re: what's wrong with my route?

I don't usually care about routes for my admin controllers since no
one except administrators see them, so if it was me I wouldn't worry
about it.

However you could probably simplify your routes:

Router::connect('/admin/islandnews/:action/*', array('controller' =>
'newsletters', 'admin' => true));

Hope that helps.

Cheers,
Adam

On Dec 31, 9:57 am, brian <bally.z...@gmail.com> wrote:
> using 1.2.0.7962
>
> The model is Newsletter but I'd like to keep the legacy path,
> "islandnews". Some of the routes are working but others are not. For
> instance, this works:
> Router::connect('/admin/islandnews',
>         array('controller' => 'newsletters', 'action' => 'index', 'admin' => true)
> );
>
> However, in that view, I set up some links using the array notation:
> $edit_link = $html->link(
>         'edit',
>         array(
>                 'controller' => 'newsletters',
>                 'action' => 'edit',
>                 $newsletter['Newsletter']['id']
>         ),
>         array('title' => 'edit this edition')
> );
>
> Now, from what I understand, the fact that I have the following route set up:
> Router::connect('/admin/islandnews/edit/:id',
>         array('controller' => 'newsletters', 'action' => 'edit', 'admin' => true),
>         array(
>                 'id' => '[0-9]?',
>                 'pass' => array('id')
>         )
> );
>
> ... should cause Cake to create this URL:http://my.domain/admin/islandnews/edit/29
>
> Instead, I get:http://my.domain/admin/newsletters/edit/29
>
> If, in the view, I give "islandnews" for the controller, the link  is
> good, but the route still is not recognised.
>
> Strangely, in my admin_add() action, I have the following:
>
> if ($this->Newsletter->save($this->data))
> {
>         $this->flash('The newsletter has been created', array('action' => 'edit'));
>
> ... which redirects me to /admin/newsletters/edit (again, the route is
> ignored) where I have:
>
> $form->create('Newsletter', array('action' => 'edit'))
>
> Now, suddenly the route is recognised and I get a form with
> action="/admin/islandnews/edit/29"
>
> However, the route fails when the form is posted. So, how/why did the
> route get written that way? What the heck am I doing wrong here?
--~--~---------~--~----~------------~-------~--~----~
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: