...

View Full Version : Handling varied paths



Nightchild
01-21-2008, 03:08 AM
I want to organize my code into sections contained in their own sub-directories. There are a few files in the app root such as an index, login and logout scripts but the rest are in their own directories.

app
... template
... ... images
... includes
... module1

My header file within the template directory will create the HTML head including the call for the CSS. The problem I am having is depending on what script (and where) that I include the header.inc.php - I have problems making sure the CSS and images are included.

How do you do this? Make sure that no matter where I call the header from it always includes the CSS and stuff correctly? I saw a post from November that touched on setting PHP's INI temporarily to include other paths. Is this how I have to do this?

Thanks

oesxyl
01-21-2008, 04:29 AM
My header file within the template directory will create the HTML head including the call for the CSS. The problem I am having is depending on what script (and where) that I include the header.inc.php - I have problems making sure the CSS and images are included.

How do you do this? Make sure that no matter where I call the header from it always includes the CSS and stuff correctly? I saw a post from November that touched on setting PHP's INI temporarily to include other paths. Is this how I have to do this?

Thanks

you can use $_SERVER['PHP_SELF'] to find the the file path relative to the document root of the server, and you allready know the path of the image or css directory. With this two elements you can compute, using realpath for example, the relative path you must use in your html element.

take a look to "alban dot lopez+php dot net at gmail dot com" post:

http://www.php.net/manual/en/function.realpath.php

about computing the shortest relative path between two folders.

best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum