I'm in a lithium layout file and I'd like to echo the name of the current controller (to use as a CSS class later). How can I obtain the current controller name?
Thanks, aeno
I assume you mean you are in a View?
If so, it's pretty simple to get the controller or other parts of the route/request ...
<?=$this->_request->controller;?>
That will get you the Controller but you can get just about anything from your route you'd need. So assuming you have a route like ...
Router::connect('/{:controller}/{:action}/{:id}');
You can use both of the following in your view:
<?=$this->_request->action;?>
<?=$this->_request->id;?>
Or you could have a fancier route like ..
Router::connect('/{:id}/{:area}/{:controller}/{:action}/');
This would be for a url like:
Now you can do something like ...
<?=$this->_request->area;?>
To get the "area" portion of the url, etc. You get the idea.