tags:

views:

55

answers:

1

Hi,

I've been thinking how to make something like this in Kohana:

domain.com/variable

the "variable" is the identifier for a user.

So, is this possible?

http://domain.com/username/controller/action

If yes, can you point me to the right direction, please?

Thanks.

+1  A: 

What happens if you have a page named "contact" and a user signs up with "contact" as a username. Which page will be displayed?

Here is an example I threw together for you.

// Pages that aren't users.
Route::set('static', '<action>', array('action' => 'sitemap|faq|terms|privacy|credits'))
->defaults(array(
    'controller' => 'static'
));

// User routing
Route::set('user', '<username>(/<controller>(/<action>))')
->defaults(array(
    'controller' => 'user',
    'action' => 'index'
));

So when this URL is called

http://example.com/sitemap

the first route is used and when

http://example.com/arnold

is called your user class and index method would be called. You can access the username variable with:

$this->request->param('username');

If you have any more questions, feel free to ask.

The Pixel Developer

related questions