• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get name of controller from view (without passing it as a variable)

#1
[eluser]blasto333[/eluser]
Is there a native way to get the name of the controller from within a view?

#2
[eluser]xwero[/eluser]
Code:
echo __CLASS__;

#3
[eluser]blasto333[/eluser]
This still has to be done from the controller because in the view the class is CI_Loader

#4
[eluser]SitesByJoe[/eluser]
You could do a good old:

Code:
<?php
$current_controller = $this->uri->segment(1);
echo $current_controller;
?>

And that would certainly work from a view. If you're talking about it happening on the client end you would need to use javascript to get the same effect.

I'm not aware of any problems that would occur using this method.

#5
[eluser]narkaT[/eluser]
Code:
get_class();

works for me so far Wink


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.