Warning: this message is detailed, but I'm really looking for some specific help, so I wanted to provide all the background up front.
I am working on a large site that is all PHP scripts, using Dreamweaver MX for editing. What I am trying to do is set up an environment where certain shared page elements can be used in a template via PHP includes, rather than DW libraries. This is to reduce the number of pages that must be synchronized when an element of the page changes.
The basic problem I'm having is one of dealing with include paths and include file references. First, it is important to me to have DreamWeaver render the included files, as they contain HTML. Related to that, I have my first questions:
- Why does DWMX only support include statements (include, require, include_once, require_once) that are alone in segment of PHP code, and only if the file name argument is enclosed in parentheses? For example, the following, both valid PHP syntax, don't get rendered:
<?php
include "include_file.inc.php"; // include ("incfile.inc.php"); renders correctly
?>
<?php
include("file1.inc.php"); // neither of these files are rendered
include("file2.inc.php"); // and any other PHP statements before or after the include prevent rendering also
?>
My second issue/question is about path names. For PHP include files, DWMX seems to understand both document and site-relative paths for include files, when it comes to rendering them. If you use a site-relative path, interestingly enough, DWMX converts it into a document-relative path in the generated temp file for a preview.
The problem is that PHP doesn't itself deal with site-relative paths. So if you have an include statement like:
<?php include("/include/incfile.inc.php"); ?>
DWMX will find it, include in the preview (due to the path mangling noted above), but when you try to view it directly from the web server in a browser, you get an error about not being able to find the file.
On the PHP side of things, I have tried two things. The first was to set the PHP config variable "doc_root" to the root directory for the site. I have tried this under WinXP/IIS and Linux/Apache, and it doesn't work for either. Note: I do not have safe mode set, and don't want to enable that (and I read somewhere that that solution won't help for include files, but I didn't test it).
My second thought was to put the root document directory into the PHP include_path, and use root-relative path names. This worked great for PHP, and DWMX worked correctly for PHP files in the root directory, since the root-relative and document-relative paths are the same. But a page one or more levels down the tree from the root will not render correctly, as I'm sure DWMX doesn't support or understand the PHP include_path.
So what's the solution to get include files that you want rendered in DWMX to work? I'm *sure I'm not the first one to grapple with this issue! Any help would be greatly appreciated.
Sincerely,
Theo Pozzy