MyBB Community Forums

Full Version: Is there any way of including php into template?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi,

Is there possible to include some php into header, i have some scripts that need php to be executed. Is there possible to include those php scripts somehow into template, i need to be inluded in header? Is there any way please, if there have to be edited some php files, just tell me where to, and how should be wriiten to work!

Thank you very much in advance!
You can add php to template. There are the php files for that. Add your code to global.php and output the variable in header template.

regards
can you just make example how should code in global.php look like, and how to include it then into template ?

Thank you
in global.php

above

eval("\$header = \"".$templates->get("header")."\";");

add

$z = "Z";
$e = "e";
$myname = "{$z}ah{$e}r";

In header template you add
{$myname}
am so here can be used like this:

$z = "include('/home/www/oglasi/oglasi.php');";
$e = "e";
$myname = "{$z}ah{$e}r";

or
$z = "
<?php
include('/home/www/oglasi/oglasi.php');
?>
";

i need this code to be put somehow into template:
<?php
}
	$nav = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? strtolower( $_SERVER['HTTP_USER_AGENT'] ) : '';

	if (stristr($nav, "msie"))
		{
		echo '<div id="subheaderie"><div id="menuie">';
		include("/home/www/include/menuie.php");
		}
	else
		{
		echo '<div id="subheader"><div id="menu">';
		include("/home/www/include/menu.php");
		}
?>

or how can be php code put in here? Please can you make example on my code?

Thank you for answering my silly questions
You cannot use php code in php code strings or templates.
so you are saying that there is no way to include any php script even so, if the code is puted into global.php or functions.php?
Of course there is but you got to do it the right way Rolleyes

Moving code modifications.
an how could i do then this, could you tell me how could i make this modification?

Thank you
Here's a code snippet of how it should look like, kind of.
<?php
ob_start();
    $nav = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? strtolower( $_SERVER['HTTP_USER_AGENT'] ) : '';

    if (stristr($nav, "msie"))
        {
        echo '<div id="subheaderie"><div id="menuie">';
        include("/home/www/include/menuie.php");
        }
    else
        {
        echo '<div id="subheader"><div id="menu">';
        include("/home/www/include/menu.php");
        }
$variable = ob_get_contents();
ob_end_clean();
?>
Now you can use {$variable} within the template.
Pages: 1 2