Using include function in Templates... what's the matter!??!

Hi all;

 I'm, working wih DWMX2004. I use to do a template page and inside that template, just set <?include "headpage.php"; ?> <?include "menu.php";?> and so on. OK, when I create a PAge from this template, it seems not to found that includes, that's because is I don't write the full path inside that includes, DW doesn't update this!!!...

So, is there anyway to make things work avoiding to have to write the full path on that includes.¿¿?? Maybe it's a problem in DW?... I don't understand.

Working with ASP, this goes well, includes are correctly updates, but not uin PHP... any help¿?

Thank you in advance!
LVL 1
jorviduAsked:
Who is Participating?
 
Jason C. LevineNo oneCommented:
You have, and I now know what the problem is.  However, the way to fix it is in the first technote:

upgrade to DW 8.

Sorry.  The second technote shows you how to kind of/sort of disable the behavior in MX2004, but this is known flaw in 2004 that they decided not to fix.  
0
 
Jason C. LevineNo oneCommented:
Hi jorvidu,

You may want to use site-relative links in the includes statements when you are in a template:

<?include "./headpage.php"; ?>
0
 
jorviduAuthor Commented:
That's exactly the problem.... include function seems not to understand relative path... at this time, the only solution for me is write the full path... and that's a mess when working on two servers, local and production...

Any more ideas?...
Thanks anyway.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
Jason C. LevineNo oneCommented:
No, you shouldn't have to do this.  That's my point.

If the include files are in the root directory, this should work no matter which server you are on:

<?include "/headpage.php"; ?>

If your sites are defined correctly, that pulls headpage.php from the site root be it local or remote.
0
 
jorviduAuthor Commented:
That was the first thing I tested, but it's not working, at least ein a a localhost environment...¿?¿?
0
 
Jason C. LevineNo oneCommented:
Hence the first part of my comment: "If your sites are defined correctly"

It sounds like you need to do some or all of the following:

1) Check the DW site definitions and pay close attention to paths.  Make sure they are all correct (local, remote, and testing).
2) When you mention localhsot environment, are you testing the PHP pages using http://localhost/?  If so, I would check your local web server and make sure it is configured to serve PHP pages and also that the site root path is defined correctly.
0
 
jorviduAuthor Commented:
Yes, I'm assured that the definition is right. Yeah, if I have a new Web in my localhost, called http://localhost/shoesweb i. e., when I refer includes as /shoesweb/inc/includefile.php, the system cannot found it...¿?¿?... Maybe it has something to do with my IIS server...I don't know how to workaround. The only way at this time is to put every page in the same level directory to have this working... writing something as ../inc/includefile.php...
¿?¿?¿?
0
 
Jason C. LevineNo oneCommented:
"when I refer includes as /shoesweb/inc/includefile.php, the system cannot found it."

Okay.  Can you post the source code for a page in localhost/shoesweb/ with the include calls.  I have a feeling your IIS and/or PHP paths may not be set correctly somewhere.

Also, this:

"The only way at this time is to put every page in the same level directory to have this working... writing something as ../inc/includefile.php..."

is correct.  ../inc/includefile.php is a correct path from http://localhost/shoesweb/  That's document relative, so what is the problem.

Now I'm confused.
0
 
jorviduAuthor Commented:
In refer at:
"The only way at this time is to put every page in the same level directory to have this working... writing something as ../inc/includefile.php...

is correct.  ../inc/includefile.php is a correct path from http://localhost/shoesweb/  That's document relative, so what is the problem.

Now I'm confused."

You know that templates in DW autochange directories in order to put i. e. path of images and other pages contained in the Template. DW changes right everything except the paths contained in includes!!!
0
 
Jason C. LevineNo oneCommented:
Okay, see this technote:

http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=52195a7

Let me know if that helps.
0
 
Jason C. LevineNo oneCommented:
0
 
jorviduAuthor Commented:
Not exactly... that's near to my problem.

Just create this test environment.
A new Web in DWMX2004
Create a template, that will be stored in Templates folder.OK.
Create a new folder from root called /inc and then create a simple php flie that contains i. e. <?echo "Dog";?>, named "incerror.php"
Ok, come back to the template and include the last file as:
<?include ("../inc/incerror.php")?>

Now, when you create a file from template, it must be in a directory from root. Try to create a template file and put it in the root... so, that's the problem... the path is not updated.

Hope I've explained well.
0
 
jorviduAuthor Commented:
I forgot, if you do the same with ASP directives, everything is done right!... ¿?¿?¿?
0
 
jorviduAuthor Commented:
Damn!!!...
I was smelling that this was a flaw... Well thank you for your full support. If you want an extra award, just take a look at your commebnts, the two technotes are the same.
;-)

Thanks master.
0
 
Jason C. LevineNo oneCommented:
Argh.

Sorry about that!  I cut and pasted the wrong one the second time.

0
 
Jason C. LevineNo oneCommented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.