我有一个包含标题(菜单导航和徽标)的 PHP 站点。
我的网站中有一个部分,我想包含一个不同的标题
,我正在为此苦苦挣扎。任何帮助,将不胜感激!
这是我的代码:
<div id="wrapper">
<? include('inc/header.inc.php'); ?>
<? require('process/build_page.php'); ?>
<? require('inc/footer.inc.php'); ?>
</div>
我想在名为“my-association”的特定部分中包含以下标题
<? include('inc/header_ma.inc.php'); ?>
process/build_page 代码如下所示:
<?
global $full_uri;
class BuildPage
{
function BuildPage()
{
global $full_uri;
if($full_uri)
{
$this->build_path();
}
else
{
exit();
}
}
function build_path()
{
global $full_uri;
$uri_array = explode("/", $full_uri); # make uri into an array divided by /
$clean_uri = array_filter($uri_array); # remove empty elements
unset($clean_uri[1]); # remove base part of uri
$clean_uri = array_values($clean_uri); #reset array key to start with 0
# if array is empty the homepage is being requested
if(empty($clean_uri)){
$clean_uri[0] = 'home';
}
# build uri to point to include file
$new_path = "content/";
$new_path .= implode("/", $clean_uri);
$new_path .= ".inc.php";
$this->build($new_path);
}
function build($path)
{
$output = "";
$output .= $this->get_include_contents($path);
echo $output;
}
function get_include_contents($filename)
{
if (is_file($filename))
{
ob_start();
include $filename;
$contents = ob_get_contents();
ob_end_clean();
return $contents;
}
return false;
}
function print_array($data)
{
echo "<pre>";
print_r($data);
echo "</pre>";
die();
}
};
$buildpage = new BuildPage();
?>
请指教!谢谢