Using include(); in a page

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:
PHP:
<?php
class Market_Loader
{
    public static function templateHook($hookName, &$content, array $hookParams, XenForo_Template_Abstract $template)
    {
        if($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:
PHP:
ob_start();
    require("market/index.php");
$myContent = ob_get_contents();
ob_end_clean();
 
$content = $myContent;
 
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.
 
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.

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