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

Changing JS/html href URLs on External Load

Discussion in 'XenForo Development Discussions' started by Claiver, Aug 13, 2013.

  1. Claiver

    Claiver Member

    So I'm loading some parts of the XenForo header in my CakePHP application. The HTML is loaded fine, and I'm also including the xenforo.js for the base JS logic to ensure the visitor bar works (with messages and alerts).

    Currently when it generates the HTML for the loaded templates, all of the URLs are relative. Since my board is located at http://mysite.com/community/, and my main page at http://mysite.com/, I need to somehow make the renderer/parser append "/community/" to the URLs.

    In addition to that, the AJAX urls in the javascript are relative as well. So when it tries to load the alerts upon hovering over it, it tries to load it from http://mysite.com/account/alerts-popup/?&_xfRequestUri=%2F&_xfNoRedirect=1&_xfResponseType=json instead of http://mysite.com/community/account/alerts-popup/etc..

    Any idea how I would best go about solving this matter? Cheers! :)
  2. JulianD

    JulianD Well-Known Member

    My best bet would be to modify the <BASE> tag to your forum path and use absolutes urls on your CakePHP application.
  3. Claiver

    Claiver Member

    Unfortunately my own application is reliant on relative pathing. I was hoping XenForo used some sort of LinkHelper to create links, this is not the case?
  4. JulianD

    JulianD Well-Known Member

    Yes, the link builder includes an option to build absolute paths but I'm not sure if you can create an addon or something else to make all urls within the forum to be absolute.
  5. Claiver

    Claiver Member

    Ahh, so there isn't a global option I could set, before the linkbuilder does his job? For example during initialization:
    XenForo_LinkBuilder::path '/community/'// instead of '/'

    // all the link-building code here
  6. JulianD

    JulianD Well-Known Member

    To be honest, I haven't dug deep enough in the link builder areas of XenForo, I'm not sure if everything goes through the same function. If that is the case, then I think you can make something like that. :)

Share This Page