On 4/24/07, Dave M G <martin@xxxxxxxxxxxxx> wrote:
PHP Users, I am developing a content management system, and one of the goals is to separate out the design entirely from the PHP scripting and content. All the PHP scripts which contain the logic that drives the site are all in the web site's root directory, where the main index.php is located. The site uses an .htaccess file that creates "user friendly URLs", so basically every time a user does anything on the site, it goes through /index.php. The intention is for the designer of the site to only have access to a subdirectory of the site called "layout". If the designer wants, he or she can have multiple styles, which would each be in their own subdirectories. So, for example, there might be a /layout/styleOne directory, and a /layout/styleTwo directory. The way a designer builds a style is with a file called "layout.php". This file contains blocks of HTML code that the designer can manipulate in order to customize the layout of the site. For example, that file would be located at /layout/styleOne/layout.php. Right now, if the designer of the site wants to make a call to an external CSS style sheet within layout.php, the designer has to write in the whole path, relative to the index.php file. For example: <style type="text/css"> @import "/layout/styleOne/style.css"; </style> But I'd like to make it so that the designer doesn't need to ever think about paths, and can state the path to the CSS file relative to layout.php, and not relative to index.php. Like so: <style type="text/css"> @import "style.css"; </style> What happens is that index.php includes a file called include.php. That file in turn includes all the PHP scripts on the site. That file includes another file called Page.php which has a way of including layout.php depending on what style the page needs. For example, styleOne or styleTwo. That's a long linear string of includes, but bottom line is, if I'm correct, that the index.php ultimately includes layout.php, and layout.php therefor acts as if it were in the same directory as index.php. I hope I have described the situation adequately. My question is, as implied above: Can I somehow manipulate any of the PHP scripts involved so that the HTML within layout.php will look first in it's own directory for inclusion of files, such as CSS and javascript and anything else? Thank you for your time and assistance. -- Dave M G Ubuntu 7.04 Feisty Fawn Kernel 2.6.20-15-generic Pentium D Dual Core Processor
This is a client side problem. After your whole PHP processing has been done, 1 final HTML page is executed. In that page you have set : <style type="text/css"> @import "style.css"; </style> Then the browser will create a NEW request, to get the style.css file. And he will request that file in the same directory the index.php file is in. So what you want is impossible, unless you're gonna create a silly browser ;) what you can do, and what i see a lot is that they let PHP open the CSS file, and display the CSS inline. Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php