I wish to use header (includes css, js and images) and footer files located in a folder called /template. These files then get included in every file down the directory for example:
/template/header.php + footer.php
/home/index.php
/products/products.php
/products/hardware/types/hardware.php
/css
/js
/images
When i use:
include (__DIR__ . "/../template/header.php");
The file is included (although i need to change each file and ad more "/../" the further down the directory i go) but all the css, js and images are broken.
here is my header (located in header.php, one of the included files):
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="images/favicon.ico">
<link rel="icon" type="image/gif" href="images/favicon.ico">
<link rel="stylesheet" type="text/css" href="../css/layout.css"/>
<link rel="stylesheet" type="text/css" href="../css/slider.css"/>
<link rel='stylesheet' type='text/css' href='../css/menus.css'/>
<link rel='stylesheet' type='text/css' href='../css/forms.css'/>
<link rel="stylesheet" href="css/jquery-ui.css" type="text/css" media="all"/>
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript" src="../js/jquery.elastic.source.js"></script>
<script type="text/javascript" src="../js/control.js"></script>
<title>APEC Energy - <?php echo($PageTitle);?> </title>
</head>
I am now trying to use a config file (which is hard to get working and still doesnt for me).
config.php (placed in root folder)(Do i need to place more information in the array, file path or directory path? if so how?):
<?php
$paths = array(
"root" => "./",
"controller" => "controller",
"stylesheets" => "css",
"images" => array(...),
"javascript" => array(...),
);
$projectName = "/";
function fInc($filePath){
global $projectName;
return '//'.$_SERVER['HTTP_HOST'].'/'.$projectName.'/'.$filePath;
}
?>
and in each .php file calling for the including file im using:
<?php
$rootDir = $_SERVER['DOCUMENT_ROOT']."/".(explode ('/', $_SERVER['PHP_SELF'])[1]);
require_once($paths['helper']['html']."template/header.php");
?>
When i use var_dump($paths), it prints out "NULL"
but just get a blank screen now?
thank you