Solved

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

Posted on 2006-06-21
16
207 Views
Last Modified: 2013-11-18
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!
0
Comment
Question by:jorvidu
  • 9
  • 7
16 Comments
 
LVL 70

Expert Comment

by:Jason C. Levine
Comment Utility
Hi jorvidu,

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

<?include "./headpage.php"; ?>
0
 
LVL 1

Author Comment

by:jorvidu
Comment Utility
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
 
LVL 70

Expert Comment

by:Jason C. Levine
Comment Utility
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
 
LVL 1

Author Comment

by:jorvidu
Comment Utility
That was the first thing I tested, but it's not working, at least ein a a localhost environment...¿?¿?
0
 
LVL 70

Expert Comment

by:Jason C. Levine
Comment Utility
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
 
LVL 1

Author Comment

by:jorvidu
Comment Utility
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
 
LVL 70

Expert Comment

by:Jason C. Levine
Comment Utility
"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
 
LVL 1

Author Comment

by:jorvidu
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 70

Expert Comment

by:Jason C. Levine
Comment Utility
Okay, see this technote:

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

Let me know if that helps.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
Comment Utility
0
 
LVL 1

Author Comment

by:jorvidu
Comment Utility
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
 
LVL 1

Author Comment

by:jorvidu
Comment Utility
I forgot, if you do the same with ASP directives, everything is done right!... ¿?¿?¿?
0
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 500 total points
Comment Utility
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
 
LVL 1

Author Comment

by:jorvidu
Comment Utility
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
 
LVL 70

Expert Comment

by:Jason C. Levine
Comment Utility
Argh.

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

0
 
LVL 70

Expert Comment

by:Jason C. Levine
Comment Utility
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now