Solved

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

Posted on 2006-06-21
16
210 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
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…

809 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