CodeIgniter Forums
Best Way to get the current controller? - 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: Best Way to get the current controller? (/showthread.php?tid=27481)



Best Way to get the current controller? - El Forum - 02-12-2010

[eluser]dsentker[/eluser]
Hey there,

in my view-file (main.view.php) i want to check if the controller 'admin' is loaded. Why that? Well, i've got this line:

Code:
<meta name="robots" content="index, follow">

And i want to change it to that:

Code:
<meta name="robots" content="noindex, nofollow">

if the admin-controller is loaded, cause google&co;should not recognize this path. What is the best way to get the current controller for my if/else inquiry?


Best Way to get the current controller? - El Forum - 02-12-2010

[eluser]Sbioko[/eluser]
You can get your controller's name using the following code:
Code:
$controller = $this->router->fetch_class();