Monday, August 30, 2010

Re: Need help from a routing "expert"

You don't even need a route...

Router::connect('/threads/*', array('controller' => 'threads',
'action' => 'index'));

This by default will become /threads/ without the route.

So remove the route and just pass this:

<?php echo $html->link('Title', array('controller' => 'threads',
$id)); ?>

Which will become: /threads/123

Which in turn can be used in the controller:

public function index($id) {
}

-Miles

On Aug 30, 6:03 am, Greg Skerman <gsker...@gmail.com> wrote:
> arghh... told you it'd be easy... thanks for that :)
>
> On Mon, Aug 30, 2010 at 10:35 PM, Andy Dirnberger <andy.dirnber...@gmail.com
>
> > wrote:
> > Router::connect('/threads/*', array('controller' => 'threads',
> > 'action' => 'index'));
>
> > On Aug 30, 7:52 am, Greg Skerman <gsker...@gmail.com> wrote:
> > > Ok so this should be fairly easy right?
>
> > > I have a few controllers (forums, threads and posts)
>
> > > The index of the forums controller shows the list of available forums
> > > The index of the threads controller shows the list of threads for a forum
> > > (so an ID is passed to the index method)
> > > The index of the posts controller shows the list of posts within a thread
> > > (so a forumID and a threadID is passed to the index method).
>
> > > So my URL's look somewhat aweful....i have /threads/index/1 etc
>
> > > what i'd really like is /threads/1
>
> > > so i tried Router::connect('/threads/:id', array('controller' =>
> > 'threads',
> > > 'action' => 'index'); to no avail... i tried playing with named arguments
> > > (which I would prefer to avoid) and still no luck.
>
> > > Surely it can't be hard to route out the action......help?
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd 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<cake-php%2Bunsubscribe@googlegroups.com>For more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en

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: