Problem defining paths inside included PHP file
Posted: Mon Feb 04, 2008 3:12 am
I'm setting up my first website using DW8/PHP5 and apache for local testing.
I've created a PHP file with code for a navigation bar which has html code pointing at various images. When I create pages in the site root directory this works fine, as the html image links are set to "images/some.gif".
However, I have set up a tree of directories for my content and when I use the include in pages below the root, the image file are no longer found as the image links start looking in the current directory.
I assume I need to add some code to the include file so the img src tag is always going to look in the correct directory no matter where the page is created. I've been trying for ages to figure this out, but so far without success. I am on the wrong track here? Here's an example:
Navbar.php
<div id="logoheader"><img src="Images/some.gif"/></div>
SiteRoot contains:
page_one
Navbar.php
SiteRoot\Images contains:
some.gif
SiteRoot\Content contains:
page_two
page_one works fine as it is created in the site root. But page_two doesn't.
Any help would be appreciated by a frustrated newbie!
Graham
I've created a PHP file with code for a navigation bar which has html code pointing at various images. When I create pages in the site root directory this works fine, as the html image links are set to "images/some.gif".
However, I have set up a tree of directories for my content and when I use the include in pages below the root, the image file are no longer found as the image links start looking in the current directory.
I assume I need to add some code to the include file so the img src tag is always going to look in the correct directory no matter where the page is created. I've been trying for ages to figure this out, but so far without success. I am on the wrong track here? Here's an example:
Navbar.php
<div id="logoheader"><img src="Images/some.gif"/></div>
SiteRoot contains:
page_one
Navbar.php
SiteRoot\Images contains:
some.gif
SiteRoot\Content contains:
page_two
page_one works fine as it is created in the site root. But page_two doesn't.
Any help would be appreciated by a frustrated newbie!
Graham