URL generation method?

Renari

Member
Is there one? I assume so since Xenforo supports using modrewrite to make more friendly URL. But I can't seem to find it.
 

Chris D

XenForo developer
Staff member
What specifically are you needing to know or trying to do?

The class responsible for building URLs is XenForo/Link.php if that helps.
 

Renari

Member
Thanks I figured it out.
Code:
$link = Xenforo_Link::buildPublicLink("members/{username}.{id}");
Will generate a link to the users profile.
 

Jake Bunce

XenForo moderator
Staff member
That works, but this is more correct:

Code:
$link = XenForo_Link::buildPublicLink('members', $user);
Where $user is the user record or is an array which contains at least the username and user_id.
 

Marcus

Well-known member
You can see that in the official xenforo code ( $this->responseRedirect ...) like here (which is a custom code):

PHP:
 return $this->responseRedirect(
XenForo_ControllerResponse_Redirect::SUCCESS,
  XenForo_Link::buildPublicLink('members/mobileedit'),
  'You just changed your mobile number'  );
 
Top