Solved

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

Posted on 2006-06-21
16
209 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
ID: 16953294
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
ID: 16953916
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
ID: 16954407
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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 1

Author Comment

by:jorvidu
ID: 16958773
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
ID: 16962014
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
ID: 16962255
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
ID: 16962433
"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
ID: 16962598
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
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 16962683
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
ID: 16962692
0
 
LVL 1

Author Comment

by:jorvidu
ID: 16962904
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
ID: 16962915
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
ID: 16962936
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
ID: 16963017
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
ID: 16963026
Argh.

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

0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 16963034
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What is the normal amount of queries 5 77
Contact Forms for Website 6 82
ColdFusion Rereplace 3 78
Form submit issue 11 85
Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

770 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