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

XF 1.2 How do I create a link in a page relative to the Xenforo root?

Discussion in 'XenForo Questions and Support' started by Stuart Wright, Sep 29, 2013.

  1. Stuart Wright

    Stuart Wright Well-Known Member

    So we're setting up Xenforo in the /community folder.
    But we're moving it to root when we go live. Can't move it to root before then because our current forums are installed in the /forums folder.

    Lots of pages link to other pages on the site. Rather than create absolute links which will break when we move the site, can we create relative links which will work now and when we move?

    What's the magic code please?
     
  2. Liam W

    Liam W Well-Known Member

    What do you mean? Do you want files in the / folder to be displayed...?

    They will by default, as long as they exist.
     
  3. Digital Doctor

    Digital Doctor Well-Known Member

    Pages, not sure.

    Moving your forum is easy.
     
  4. Brogan

    Brogan XenForo Moderator Staff Member

    You should always use xen:link for internal URLs.

    For example:
    Code:
    <a href="{xen:link 'threads/thread-title.71/'}">Thread</a>
    Code:
    <a href="{xen:link 'pages/page-title/'}">{xen:phrase page_name}</a>
     
  5. Digital Doctor

    Digital Doctor Well-Known Member

    Does this work ?

    Code:
    <a href="{xen:link 'threads/.71/'}">Thread</a>
     
  6. Digital Doctor

    Digital Doctor Well-Known Member

  7. Stuart Wright

    Stuart Wright Well-Known Member

    Awesome, thanks.
     
  8. Adam Howard

    Adam Howard Well-Known Member

    @Brogan can you please add this into your Q & A resource. It would be very helpful to recall this at a later time.
     
  9. Stuart Wright

    Stuart Wright Well-Known Member

    Confirmed that this is working as expected and I'll use this in all my internal links.(y)
     
  10. Digital Doctor

    Digital Doctor Well-Known Member

    xen:link for internal URLs.
    <a href="{xen:link 'threads/thread-title.71/'}">Thread</a>

    ....
    Is there a way to make it easy for people to use xen:link ? like a popup ?
     
  11. Jeremy

    Jeremy XenForo Moderator Staff Member

    Considering that there is no "editor" in the backend with pop ups, this would be a break and confusing behavior. The syntax is simple, and a pop up won't simplify it any further.
     
    SneakyDave likes this.

Share This Page