CodeIgniter Forums
Grabing Class and function name for use in a libraries - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Grabing Class and function name for use in a libraries (/showthread.php?tid=31429)



Grabing Class and function name for use in a libraries - El Forum - 06-18-2010

[eluser]The Casual Bot[/eluser]
hi all,

im trying to make a auth libary that will allow and diallow access the controller and function

so i trying to get the class and function name and the easy way i could think of doing this was the uri class but this seems to just return '0'

any ideas / suggestions how i can do this

i now i can pass the name in a var but want to try to avoid that


Grabing Class and function name for use in a libraries - El Forum - 06-18-2010

[eluser]WanWizard[/eluser]
You mean the controller and method called thru the URI?

Code:
$controller = $this->uri->rsegment(1);
$method = $this->uri->rsegment(2);

Or in case you're intrested in the URI before routing

Code:
$controller = $this->uri->segment(1);
$method = $this->uri->segment(2);



Grabing Class and function name for use in a libraries - El Forum - 06-18-2010

[eluser]The Casual Bot[/eluser]
yeah kinda got this to work

that is what i was doing

but i had the following

Code:
$CI->load->library('uri');

clearly i didnt read the user guide as it seems by calling the class it stop it from be called

once this line was removed it started to work fine


Grabing Class and function name for use in a libraries - El Forum - 06-18-2010

[eluser]The Casual Bot[/eluser]
but thanks

anyway


Big Grin


Grabing Class and function name for use in a libraries - El Forum - 06-18-2010

[eluser]danmontgomery[/eluser]
Code:
$this->router->class;
$this->router->method;