• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 2.0 How to get current page controller name and action?

Liam W

Well-known member
#2
I can't see anything that'll let you get it directly (the route match doesn't seem to be stored anywhere), but this works:
PHP:
\XF::app()->router()->routeToController(\XF::app()->request()->getRoutePath());
(The XF class is available in templates)

Liam
 

Mike

XenForo developer
Staff member
#3
It's part of the AbstractReply object, but it's not likely to be directly exposed in most cases. You'd likely need to trigger some code somewhere where the reply object is available (and complete).