Forum Moderators: coopster

Message Too Old, No Replies

Organizing site directories when using PHP

How should one go about creating a directory structure with includes?

         

mr_nabo

8:37 am on May 18, 2007 (gmt 0)

10+ Year Member



Now that I have to create a large site, I wanted to create a directory for each section and sub-section of my site as I've done in the past.

However, using includes means that relative urls do not work when viewing a page within a directory. Am I forced to use absolute urls for includes and images etc.?

Just wondering how the majority of you structure your sites when they get larger than the average brochure-style site...

Thanks

barns101

9:42 am on May 18, 2007 (gmt 0)

10+ Year Member



Yes, you'll have to use absolute paths. I use includes like so:


<?php include($_SERVER["DOCUMENT_ROOT"]."/includes/menu.php");?>

and images like this:


<img src="/wherever/whatever.png" alt="whatever">

mr_nabo

9:48 am on May 18, 2007 (gmt 0)

10+ Year Member



Superb, thanks for that Barns101.

That's two speedy solutions I've got today. I love this forum.