Solved

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

Posted on 2006-06-21
16
208 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

914 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

18 Experts available now in Live!

Get 1:1 Help Now