Route match for 'resources'

Valhalla

Well-known member
Hello,

What is the best way to find the current route? I want something that will work with any Route Filters that may be in place.

I'm hoping to use something similar to the code below.

PHP:
public static function frontControllerPreView(XenForo_FrontController $fc, XenForo_ControllerResponse_Abstract &$controllerResponse, XenForo_ViewRenderer_Abstract &$viewRenderer, array &$containerParams)
{
     $route = $fc->route();
     if (!XenForo_Visitor::getUserId() && $route != 'resources')
     {
          $containerParams += array(
               'containerTemplate' => 'LOGIN_PAGE_CONTAINER',
               'contentTemplate' => 'error_with_login'
          );
     }
}

Thanks,
 
Last edited:
PHP:
$route = $fc->route();
if (!XenForo_Visitor::getUserId() && $route->getMajorSection() != 'resources')
{

}
 
Another thing, for anyone finding the above - I couldn't set the 'contentTemplate' using $containerParams.

Instead,

PHP:
$controllerResponse->templateName = 'error_with_login';
 
Top Bottom