Welcome Guest, Not a member yet? Register   Sign In
Get Parameter passed to the action in the post_controller_constructor hook
#1

[eluser]Unknown[/eluser]
I' m trying to create a ACL (for and in CodeIgniter) and got stuck at one point.

I cannot figure out how to get the parameter passed to method. For example the url looks like this:
http://ci.dev/controller/action/31

I managed to get the controller and method/action like this:

Code:
$class = $CI->router->fetch_class();
$method = $CI->router->fetch_method();
However I cannot figure out how to get the parameter (in this example 31).
This is kinda essential for me, since I want to control whether a user is allowed to edit items which belong to another user.

I do not want to use any kind of URI-fetching, just because the route might look different sometimes, e.g.: http://ci.dev/controller/31/action

I want to be prepared for this. Any help is very appreciated. Thanks in advanced.
#2

[eluser]TheFuzzy0ne[/eluser]
If you extend CI_Controller, you can use _remap to grab the parameters, but that seems counter-intuitive. I *think* [url="http://ellislab.com/codeigniter/user-guide/libraries/uri.html"]$this->uri->rsegments()[/url] is what you're looking for. It takes any routing into account.
#3

[eluser]Unknown[/eluser]
Yeah that works like a charm! Thank ya!




Theme © iAndrew 2016 - Forum software by © MyBB