MyBB Community Forums

Full Version: including .php in templates
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello,

I'm trying to edit the Crystal Black template so it'll include a file called "display.php" in the footer of the page. the argument I've been trying to use is as follows:

<center> <? include ("display.php"); ?> </center>

The file is in the root directory of the forums and so far I didn't have any luck, I tried many different methods to include it.

Help is appreciated, thanks in advance!
You can't use PHP in Templates.
LeX- Wrote:You can't use PHP in Templates.

So there is absolutly no way in hell I will include this file _somehow_, I dont mind editing core MyBB files, in the footer of my page?
Use a plugin instead.

Code in templates are eval'd, so <? and ?> make absolutely no sense in a template...
In global.php, find:
eval("\$footer = \"".$templates->get("footer")."\";");
Before that line, add:
ob_start();
include 'display.php';
$displaystuff = ob_get_clean();

And in your footer template, put
{$displaystuff}
where you want the code to show up.
DennisTT Wrote:In global.php, find:
eval("\$footer = \"".$templates->get("footer")."\";");
Before that line, add:
ob_start();
include 'display.php';
$displaystuff = ob_get_clean();

And in your footer template, put
{$displaystuff}
where you want the code to show up.

Thank you very much. Will try to test it now.

EDIT: Works 100%, thanks again!
Glad it's working for you Smile
Didn't work for me Sad
I've put
ob_start();
include 'foto.php';
$foto = ob_get_clean();
before
eval("\$footer = \"".$templates->get("footer")."\";");
then I added
{$foto}
into footer template.

My board is www.vitz-omsk.com

foto.php is located in the root directory

I'm trying to use cpmfetch script. If you point your browser to www.vitz-omsk.com/foto.php you'll see

Quote:Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home2/evgeniy/public_html/omsk/inc/db_mysql.php on line 665

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home2/evgeniy/public_html/omsk/inc/db_mysql.php on line 665

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home2/evgeniy/public_html/omsk/inc/db_mysql.php on line 665

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home2/evgeniy/public_html/omsk/inc/db_mysql.php on line 665

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home2/evgeniy/public_html/omsk/inc/db_mysql.php on line 665

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home2/evgeniy/public_html/omsk/inc/db_mysql.php on line 665

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home2/evgeniy/public_html/omsk/inc/db_mysql.php on line 665
guys help me please Smile
Try instead of
include 'foto.php';
use this:
include 'http://www.vitz-omsk.com/foto.php';
Pages: 1 2