homepage Welcome to WebmasterWorld Guest from 54.198.157.6
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Dreamweaver and Php Include files
Banging my head against a wall, getting nowhere
TravelSite




msg:1283485
 3:45 pm on Oct 4, 2005 (gmt 0)

I have been attempting to use path names such as "/include/index.htm" in include files so that I can see what a page looks like when working on it in Dreamweaver.

I tried the following:
<? include("/include/top/index.inc")?>
Dreamweaver shows the page with the include files (just like it does in asp) - but the server doesn't include them.

I then realised that the server looks at its own directory structure when using this format. But changing the line to:
<? include("/home/w/e/website/public_html/include/top/index.inc")?>
doesn't help as dreamweaver stops showing the include file.

Basically I can't seem to get a work around that allows the includes to render correctly on the server AND appear in dreamweaver.

My site is large and has many sub directories - so having to do <? include("../../../top/index.inc")?> becomes a pain and kind of defeats some of the simplicity of include files.

Is there a simple trick that I'm missing?

 

ran_dizolph




msg:1283486
 3:58 pm on Oct 4, 2005 (gmt 0)

try is like this;

<?php include ".../.../.../whatever.inc" ;?>

looks like you're leaving off the semi-colon.

jatar_k




msg:1283487
 4:01 pm on Oct 4, 2005 (gmt 0)

I am not sure how DW treats it but you could also try

<? include $_SERVER['DOCUMENT_ROOT'] . '/include/top/index.inc';?>

I don't use the parentheses and I use single quotes around non parsed strings but the only real difference is using DOCUMENT_ROOT

that would be the best syntax but I am not sure how DW will like it.

TravelSite




msg:1283488
 4:24 pm on Oct 4, 2005 (gmt 0)

ran_dizolph,

thanks for the input - but a semi-colon is not required when you have only the one statement/line.

jatar_k,

thanks for the method - but the include files still won't appear in dreamweaver :(

TravelSite




msg:1283489
 8:32 am on Oct 5, 2005 (gmt 0)

No one found a way to do this in Dreamweaver?

martinibuster




msg:1283490
 9:32 am on Oct 5, 2005 (gmt 0)

In Dreamweaver go into code view.

Then place your cursor where you want the include to appear.

Then do this:
Insert > Script Objects > Server-Side Include >

A box will then open up that will allow you to navigate to the file you want to include.

The resulting code will resemble this:

<?php require_once('include-file-folder/nameofinclude.inc');?>

If you do it like that, you will be able to see the page as it is layed out while in "Design View" (i.e. wysiwyg).

You will not be able to click and edit the included portions in wysiwyg mode, though. You'll have to edit those by hand in Code View from within the include files themselves (or use your favorite text/whatever editor).

Of course, if you're comfy with hand coding then just code your includes like this and you'll be able to see them in Dreamweaver's "Design View":

<?php require_once('include-file-folder/nameofinclude.inc');?>

TravelSite




msg:1283491
 12:26 pm on Oct 6, 2005 (gmt 0)

Hi Martinibuster,

Thanks for your response but I think you've misunderstood me.

I have designed a layout for a site making use of php include files. Other designers (not familiar with php) will be working independently from me on the central content part of each page. They use Dreamweaver.

As they work on adding the content, I'd like them to be able to see the include files on the page - so that they can see the entire page as they add content, without having to upload it. This gives them a better sense of what colours to use, and they are used to seeing the full page as they work.

However I found that if I use a line of code such as:
<?php require_once('http://www.XYZ.co.uk/include/bottom/index.inc');?>
Dreamweaver doesn't show it - so the designer can't see what the page looks like unless they upload it.

I then tried the following line:
<?php require_once('/include/bottom/index.inc');?>
This showed up in dreamweaver - so that designers could see what the "final" page looked like. When I uploaded it and made it live however the include files failed to appear - the above path doesn't seem to be valid php.

So I investigated a little more, and changed the line to:
<?php require_once('/home/w/e/webhotelsuk/public_html/include/bottom/index.inc');?>
...which works fine on the server - but doesn't appear on Dreamweaver.

The one way in which I can get Dreamweaver to show the include files is to use relative addressing - such as:
<?php require_once('include/bottom/index.inc');?>
I'll use this if I have to - but its a bit of a pain as I use lots of sub directories hence will have to do "../../../include/bottom/index.inc" a lot! I'm also used to using paths such as "/contact-us/" for links, and "/images/logo.jpg" (so that I can easily copy pages into other directories without having to change any links).

martinibuster




msg:1283492
 3:47 pm on Oct 6, 2005 (gmt 0)

The one way in which I can get Dreamweaver to show the include files is to use relative addressing - such as:
<?php require_once('include/bottom/index.inc');?>
I'll use this if I have to - but its a bit of a pain as I use lots of sub directories hence will have to do "../../../include/bottom/index.inc" a lot!

I fully understand what you're after, however the above is what works for me. I don't have any other solutions to offer.

One workaround for dealing with sub-sub-directories and their include files is to just copy the include folders deep into the hierarchy so that <?php require_once('include/bottom/index.inc');?> will always work no matter how deep you are.

Perhaps it's not as elegant as you would like it to be, but it will save you some time having to recode for multiple subdirectory paths.

Good luck.

Sarah Atkinson




msg:1283493
 5:33 pm on Oct 6, 2005 (gmt 0)

There is a checkbox on a menu somewhere preferences or something not sure exsactly. This box must be checked for dreamweaver to desplay include files. Might be under site definition.

I think it says show includes. Might take more memory

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved