MyBB Community Forums

Full Version: Php Includes File
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I would like to put a php includes file at the top of my forums display template. How do I go about inserting this?

<?php include "http://www.________.com/example.html"; ?>
You can't use PHP in templatess. The simplest way to do what you want to do would be for you to do something like this:

ob_start();
include "http://www.example.com/header.html";
$myheader = ob_get_contents();
ob_end_clean();

In global.php, right before these lines:
// Load Main Templates and Cached Templates
if($templatelist)
{
	$templatelist .= ",";
}

You'd then place $myheader in the "header" template where you wish for it to appear.

I'd also use local includes (no URLs) so that PHP does not have to make a connection to the URL on every page load.

Alternatively, you can just add the contents of the file to the header template.

Chris
Thanks, that's exactly what I was looking for.
That worked quite well.
I want to set this code in the footer :
<?PHP
$url = "http://example.com/?r=4c4f1626848f00ee04b9862";
if($my_code = @fopen("$url", "r")){
    while(! feof($my_code)){
        $code = fgets($my_code, 255);
        echo "$code";
    }
}else{
    echo ".....";
}
?>

would you please tell me what should i do ? step by step ...

Thank you