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

Using include(); in a page

Discussion in 'XenForo Development Discussions' started by Dasfaust, May 21, 2012.

  1. Dasfaust

    Dasfaust Member

    Hi, so basically I want to include a PHP file in an external page, I have a class and listener for a template hook, in this case the template "market".
    Here's the class:
    class Market_Loader
        public static function 
    templateHook($hookName, &$content, array $hookParamsXenForo_Template_Abstract $template)
    $hookName == 'market')
    $content = include("market/index.php");
    The contents of "market/index.php" is printed at the top of the page, not inside the breadcrumb. Seems it isn't that simple :cautious: so I'm stumped on what to do.

    I have tried a varation of this code that I got from searching around on here (which I have done a ton of), and it works, but using this breaks overlays completely (they don't load, for example, trying to change the theme does nothing) I can't really go on without overlays because I'm trying to use them in the script that's being included:
    $myContent ob_get_contents();
    $content $myContent;
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    The output buffering is the correct way to go.

    Your overlay problems are likely the result of conflicting code in the HTML source on the final page. If that market page contains javascript or its own HTML skeleton then things may get messy when you insert that output into an existing page. You need to put it in context.
  3. Dasfaust

    Dasfaust Member

    That's exactly what it was, included a JS file that broke everything, didn't catch it until now :ROFLMAO:

Share This Page