Welcome Guest, Not a member yet? Register   Sign In
How to retrieve a variable from URL before the controller?
#1

[eluser]falmp[/eluser]
My application will run for several users. So for instance, I have the controller bike. I can view/add/delete/update bikes by accessing the URLs:

/bike/view
/bike/add
/bike/delete
/bike/update

Now, I want each user can access this controller by these URLs:

/bill/bike/view
/bill/bike/add
/bill/bike/delete
/bill/bike/update

/john/bike/view
/john/bike/add
/john/bike/delete
/john/bike/update

I know that my whole application will always be accessed by a context (/user/). But I don't know what more segments I'll have on my URI. How can I get this variable?

I was thinking in using routes, but I'm not sure it'd work or if it's the best solution:

Code:
$route[':any/(:any)'] = '$1';
$route[':any'] = $route['default_controller'];

$context = $this->uri->segment(1, 'default_context');

Is this the best solution?

Ideas?
#2

[eluser]falmp[/eluser]
Edited my first post.
#3

[eluser]gyo[/eluser]
You could give a look to "Hooks" in the user guide:

http://ellislab.com/codeigniter/user-gui...hooks.html

Hope it helps.
gyo
#4

[eluser]xwero[/eluser]
http://ellislab.com/forums/viewreply/543955/
#5

[eluser]falmp[/eluser]
[quote author="xwero" date="1236557074"]http://ellislab.com/forums/viewreply/543955/[/quote]

Ok, good, it's the same solution I came up. Guess it's the way to do it. Wink

Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB