Welcome Guest, Not a member yet? Register   Sign In
VC names
#1

[eluser]Nevio[/eluser]
Hi people.

Maybe I'm stupid ( didn't found solution over search function ) but I'm interested if there is any methods like

get_controller_name() or get_view_name()?

I really need em and if there is no solutions like this that I know to develop it.

Cheers.
#2

[eluser]xwero[/eluser]
The "heavy" way to get the controller is
Code:
$RTR =& load_class('Router');

$class  = $RTR->fetch_class();
The lean way is
Code:
$class = $this->uri->rsegment(1);
I'm not sure why you should need to get the view name as it is the last stage of the page rendering. If you want to change the output you can add a _output function to the controller and if you want this for all/most controllers you can add a post_controller hook.
#3

[eluser]wiredesignz[/eluser]
The router class has been available as an object variable since CI 1.7, like so
Code:
$this->router->fetch_class()
#4

[eluser]xwero[/eluser]
that is good to know.
#5

[eluser]brianw1975[/eluser]
call me crazy but can't you use the get_class() function? (assuming you are using PHP5.0+)

http://us.php.net/get_class
#6

[eluser]louis w[/eluser]
Or even __CLASS__
#7

[eluser]Nevio[/eluser]
Hehehe. Yea I can. Now what I'm doin.

Finding out controller and view to be able automatically load javascript page for it based on controller and view position. Because there can be used rewite route, it can be a little bit buggy if I do it over "normal" way. ( need to know which method, class and view loaded in order to be able do it how I like. )

Want to brainstorm complete CI so I'm looking for a hard way always Big Grin

Thanks for info. I really appreciate it. Now I go play a little bit with it.
Anyway, now I found it lol. Sorry for that, but kinda sometimes I know to ask really stupid questions indeed.




Theme © iAndrew 2016 - Forum software by © MyBB