XF 2.0 How do you buildLink directly to admin/public areas?

Jaxel

Well-known member
$this->buildLink('threads', $thread) will assume the context of whatever area you are in... how can I force it to go to an admin/public area instead?
 
I suspect passing $router. From the Docs:

Code:
public static function homePageUrl(&$homePageUrl, \XF\Mvc\Router $router)
{
    $homePageUrl = $router->buildLink('canonical:portal');
}
 
I think I figured something out:
Code:
                $router = \XF::app()['router.admin'];
                return $this->redirect($router->buildLink('ewr-porta/articles'));
There has got to be a simply way though...
 
Would this work?

$this->router('admin')->buildLink('ewr-porta/articles')

another option

Code:
return \XF::app()->router('admin')->buildLink('ewr-porta/articles');
 
Last edited:
Pretty sure you can use link(‘admin:tools/whatever’) or link(‘public:something’)
 
With xenforo 2, other case:
XF::start($dir);
$app = XF::setupApp('XF\Pub\App');
$app->start();
$router = $app->router();
$router->buildLink('threads', $thread)
 
Back
Top Bottom