Forum Moderators: coopster

Message Too Old, No Replies

PHP Includes and DW Templates

Creating bad hrefs in sub directories

         

aaronjf

4:40 pm on Feb 23, 2006 (gmt 0)

10+ Year Member



Having a strange problem. The cart I am working on makes heavy use "include" which is just fine with me as it keeps the amount of code sitting infront of my face at any one time minimal. I made a DW template for this cart and tried to adhere explicitly to the structure and spirit of this cart.

The problem I am having is with the refs. Pages at the root of the site will only properly call the incuded files if I right the ref like this <?php include "xyz/inc/xyz.php"?> and that makes sence. However, when I try to make links relitave like <?php include "../xyz/inc/xyz.php"?> I get error messages when I view the page saying no such luck basically. But, pages that are in subdirectories like this. Tried "/xyz/" too, but no luck. I also tried using the full url of the site, but that gave me the same problem no matter where the file was.

I would really like to be about to keep using my template the way it was supposed to be used and have files in subdirectories. I hate throwing all my files in the root directory. Can any body tell me what I am doing wrong?

Sorry if this seems like a dumb question. I am pretty new to PHP, mostly a graphics and css jock. I have never had this kind of problem with just xhtml.

jatar_k

6:20 pm on Feb 23, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



includes are basd on file structure so you can have problems with local and server paths being different

have you tried the doc root way?

include $_SERVER['DOCUMENT_ROOT'] . '/path/to/template.php';

that's really the best way to do it, not sure if DW will like that or not. The other option might be to look around for a setting that sets the root directory. I am not sure if there is one but there should be.

aaronjf

6:22 pm on Feb 23, 2006 (gmt 0)

10+ Year Member



Cool, thanks Jatar. I will give it a wirl and let you know.

aaronjf

6:32 pm on Feb 23, 2006 (gmt 0)

10+ Year Member



Perfect.. That worked like a champ. Thanks