XF 2.0 What is the null in account_visitor_menu logout?

LPH

Well-known member
Hi

I'm working on a logout form external to XenForo 2. In XenForo 2, the template account_visitor_menu builds a link with a null in it. What is the null referencing?

Code:
<a href="{{ link('logout', null, {'t': csrf_token()}) }}" class="menu-linkRow">{{ phrase('log_out') }}</a>

Currently, my form is based on XenForo 1, which had a redirect.

Code:
echo '<a class="xenword_logout logout" href="' . \XF::app()->router()->buildLink( 'canonical:logout', $visitor, array(
      't' => htmlspecialchars(\XF::app()->container( 'csrf.token' ) ),
      'redirect' => $redirect_out
   ) ) . '">Logout</a>';

I'm thinking the redirect needs to be removed in the array because XenForo 2 doesn't support it but I'm not clear if a null needs to be included. Any help would be appreciated.
 
The null is passed because the second argument to the link function is used for building route parameters. For the logout route, there are no route parameters.
 
It doesn't hurt anything, but yeah, there's no need to pass anything in for the second argument.
 
So the second argument should be null, the third should match the array I have, and the fourth in mine should be removed because there isn't a redirect. Correct?

This leads to:

PHP:
echo '<a class="xenword_logout logout" href="' . \XF::app()->router()->buildLink( 'canonical:logout', null, array(
      't' => htmlspecialchars(\XF::app()->container( 'csrf.token' ) )
   ) ) . '">Logout</a>';
 
Top Bottom