if you are going for slugs with the controller prefixed (/consulting/
some_slug_of_mine) and not application-global slugs (/
a_globally_unique_slug) then you don't really have to do anything to
the routing settings.

I have just gone from a controller with:

function view($id) {
    $this->data = $this->Model->findById($id);
}

to:

function view($slug) {
    $this->data = $this->Model->findBySlug($slug);
}

Those were just a liiitle abbreviated. As long as the slugs are kept
unique you can treat them like the id in finds.




On Aug 18, 12:46 pm, Taff <taff.law...@googlemail.com> wrote:
> After reading throughhttp://book.cakephp.org/view/46/Routes-Configuration
> along withhttp://c7y.phparch.com/c/entry/1/art,cake-seoand pottering
> around for quite some time, I have come to the conclusion that I need
> some help. Here is the scenario:
>
> I am rerouting a controllername to a different name that is SEO
> friendlier:
>
> Router::connect('/consulting/:action/*', array('controller' =>
> 'consultingskills', 'action' => 'index'));
>
> This works just fine, and I can now go to site/consulting/view/4 and
> it will load the relevant information.
>
> How would I go about routing to make a URL such as site/consulting/seo
> redirect to site/consultingskills/view/4
>
> whereby id 4 in the database has a slug called "seo".
>
> I found a random post with
>
> Router::connect('/consultingskills/:slug',
>         array('controller' => 'consultingskills', 'action' => 'view'),
>         array('slug' => '[-_A-Za-z0-9]+')
>         );
>
> Can anyone walk me through what steps I need to take?
> Thanks,
> Taff
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to