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

URL generation method?

Discussion in 'XenForo Development Discussions' started by Renari, Dec 11, 2012.

  1. Renari

    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.
  2. cclaerhout

    cclaerhout Well-Known Member

    =>Use Full Friendly URLs
  3. Renari

    Renari Member

    I'm referring to generating URL using PHP. Not the option to turn it on.
  4. Chris D

    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.
    Jake Bunce likes this.
  5. Renari

    Renari Member

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

    Jake Bunce XenForo Moderator Staff Member

    That works, but this is more correct:

    $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.
    Jarod and Chris D like this.
  7. Renari

    Renari Member

    Thanks, Jake.
  8. Marcus

    Marcus Well-Known Member

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

     return $this->responseRedirect(
    'You just changed your mobile number'  );

Share This Page