If I didn;t use the <base> tag, and kept with using the $projectRoot variable I ahve been using up until now, is there something I could run to swpa the direction of the slashes so the path would be corrct for the stylesheet links?
It will never work. $projectRoot contains the system file path for example C:\User\some\path\here This will not work for a web site. You need to cut off the part the relates to the web root where. The web root would be IANA — Example domains the root is the last slash “/” so example.com/index.php would be at the web root.
Hmmm, So i’m basically back where I was the other day when I posted about this file path issue.
Maybe you guys in this thread can find me a decent solution.
Here’s the situation:
I have my webroot folder - “www”
Inside that, each folder is a single project or website.
Those project folders each contain for example:
includes
styles
scripts
index.php
about.php
contact.php
shop.php
The includes folder has both a top.php and a bottom.php file which are icnluded into each of the main site pages at the top and bottom respectively.
The styles.css and script.js pages are linked to from the top.php include and are stored in there respective folders
So basically, top.php includes the styles and the scripts and the site pages include top and bottom.
Now, that works fine for the site but then, I added a new folder in the project called “admin”.
This folder houses all the pages for the CMS for that particular site. in there I ahve the main CMS pages and on those I too want to include the sites top and bottom pages so the CMS keeps the same style as the main site. I can include the top and bottom pages but what fails is that the file path to the styles.css and script.js files is now incorrect as we are another folder into the folder hierarchy.
So, If I prepended $path 3 to the path to my stylesheet in the top.php page, will it work from the main site pages and the pages within the admin folder?
That is because its not for PHP to use, it is for your links in HTML.
Use your current method of $projectRoot for PHP but use the method I provided for HTML links.