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

XF 1.4 Is there a way to grab the current URL using a {xx} command?

Discussion in 'XenForo Questions and Support' started by MarkMark, Jun 3, 2015.

  1. MarkMark

    MarkMark Member

    This is a little hard to explain, but I am trying to create a Notice that includes a link that is relative to the page currently being viewed.

    Essentially I'm trying to do the following:
    <a href="{current_url}/my_own_variable">
    Sadly current_url is just made up, but I'm hoping there might be a way to grab the current URL, a bit like how you can grab the current username using {name}.
  2. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member


    EDIT: Oops... you were talking about notices... this wont work :(
  3. MarkMark

    MarkMark Member

    As I essentially just need to add "calendar-add" after the current URL, I thought I could just go for:

    <a href="/calendar-add">click here</a>
    Sadly, because XenForo uses a Base tag in the header, this doesn't work.
  4. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    Okay, so I did a little digging for you and found that creating a simple event listener to add the value of the current URI to the notice is possible :D
  5. MarkMark

    MarkMark Member

    Thanks for that. In the end I just used javascript, and the document.URL variable. So created:

    <a href="javascript:location.replace(document.URL + 'calendar-add')">Link</a>
    Seems to work.

Share This Page