I am creating quite a complex web application. I like to use php to help reduce the amount of repetitive code that I end up using, creating page plugins if you like.
an example of of a section of code looks like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<?php require_once("root/html_classes/head_links.html"); ?>
<link href="home/css/home.css" rel="stylesheet" type="text/css" />
<title>Texation</title>
</head>
as you can see there is a <?php ?>
reference in the above section. As this project is going to be so large I have decided to have an ultra organised file structure for all the pages, scripts, javascript, css ect elements. But it causes me 1 tiny issue.
when I create the modules linked above they themselves have references to images or other scripts and css docs that they use, but this form of inserting html means that all the directory paths need to change for every page they are inserted into, for instance,
when I use them on the index.php page the path to an image in the menu.html would be "root/images/someimage.jpg" but if I use it on the login script the path to the same image would need to be "../images/someimage.jpg"
could anyone suggest a way of making these paths dynamic taking into account the currant position within the directory structure the page they are "inserted" into is ?
I though about using php to build them something like
'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/root/images/someimage.jpg'
but cannot quite get that to work either...
Thank you for your time, any suggestions are very welcome and appreciated.