Personally, I'd create a slug for the user with their first & last
names. There's a SluggableBehavior you can use for that (though, I
believe that functionality may be built-in now somewhere). Whatever
you use, you'll want to ensure that punctuation characters are dropped
and that accented characters are properly mapped to ascii equivalents.
As for having these pages available from root, just create a route like:
Router::connect(
'/:slug',
array('controller' => 'your_controller', 'action' => 'your_action'),
array('slug' => '/[_-a-z0-9]/', 'pass' => 'slug')
);
This assumes that your slugs consist of lowercase characters, digits,
hyphen, or underscore only. The slug will be passed to your action:
function my_action($slug = null) {}
Of course, you'll need to specify every other possible route before
this one and ensure that nobody can create a slug identical to any of
your controller routes.
On Fri, Jan 23, 2009 at 10:18 PM, TC <[email protected]> wrote:
>
> Hi there,
>
> I have a project that needs me to do this:
>
> Through an admin area users can create their own "Slug" so they can
> reach their own pages, for example one create his name "cake", then
> his page can be reached as: http://www.example.com/cake, another one
> create name "php" so his page can be reached as: http://www.example.com/php.
>
> Obviously their pages are almost the same but just some specific
> texts, so I think it only need one controller, but how can I create
> specific names in the URL for them?
>
> Please help, thank you in advance!
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---