Re: Here is a silly question
| From: | tedd | Date: | Mon, 03 Apr 2006 19:24:23 +0000 |
| Subject: | Re: Here is a silly question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-233144@lists.php.net to get a copy of this message | ||
At 9:54 AM -0600 4/3/06, Mace Eliason wrote:
Hi, This is come thing that I have struggled with now and again. I usaually us php code to make it work, but was wondering how others deal with this I use includes in most of the web applications that I work on to include the header, footer, menu etc. The problem that I always run into as a project gets bigger is my links to pages. If all the files are in the root directory theres no problem. If I have some files in a folder and call my menu for example <? include("../menu.php"); ?> I have to call if from the parent directory. But then of course all the links are wrong. Root becomes the calling directory. I usually use a php variable to place the ../ if its needed. How does everyone else deal with this type of problem. I have a times places an extra copy of the footer, menu, header etc in each directory but it is a pain to change links when you have multiple locations to do it in. Thanks for any suggestions. I would be nice to have a simple way to have my include files in a common place that works and keeps the links right. ScandogMace: I do it like you do and live with it. I keep all my common includes in one include folder. If I move a project folder down a level, then I change all my includes in it like -- 'include( "includes/opendb.php")' to 'include( "../includes/opendb.php")' . However, I have given it some thought about changing it to an absolute url like -- $_SERVER['DOCUMENT_ROOT'] . "/includes/opendb.php" -- and that way then it doesn't matter how deep you go with your projects. So, now that you mentioned it -- I think I'll change it. I can do an entire site find/replace in GoLive. Thanks for asking. tedd -- -------------------------------------------------------------------------------- http://sperling.com