Forum Moderators: open
This is css and website issues related, sorry if is is not in the best forum.
I am developing a php template driven site which is static in some paces and dynamic in others.
I have header, middle and footer. The problem comes when I move to a different folder. The css does not work as I have a relative path. Apart from linking from the absolute path (C:/dir/dir2/css/main.css) is there any advice that can be offered.
This has me stumped!
Cheers
<?php include($_SERVER["DOCUMENT_ROOT"]."/includes/menu.php");?>
This works on my desktop (Apache 2 on Win2k) and on my server (Zeus 4.2 on Solaris 9).
If your CSS [w3.org] folder is off the root...
How could it be not off the URI namespace root? If it were not there would be no way to access it by using a URL and external style sheets need to be included by a URL reference (unless you want to use a local stylesheet). In fact if it were not off the URI namespace root it would not be at all, since there is nothing within the URI namespace that is not somewhere below root.
For including PHP [php.net] files using [url=http://www.php.net/include]include() [php.net][/url] or [url=http://www.php.net/require]require() [php.net][/url] this may be otherwise (i.e. they need not reside below the URI root but they will reside below the filesystem root) since they take a local path as an argument as well as a URI.
Andreas
I am still having what seems to be rudimentary difficulties with this in some cases, it could live with it if it did not work across the board but it works when calling a CSS file from a header page.
include("C:phpdev/www/dir1/dir2/file.php");
The above works but when I try an use the absolute path like this:
/dir1/dir2/file.php
It throws a wobbler and says it cannot find that path. Am I missing something?
Warning: Failed opening '/dir1/dir1/file.php' for inclusion (include_path='.;C:/phpdev/php/includes;C:/phpdev/php/class') in
Therefore the format "../directory/page.inc" works for all level 1 pages. E.g. linking to "../css/..." or selecting includes "../includes/..."
The directory structure is flat, but the linking structure can still appear to be a pyramid. It works for a few 100 pages, but there is probably an upper limit where a true directory structure is required for maintainability.