Forum Moderators: phranque

Message Too Old, No Replies

Include Methods

The alphabet soup of including content.

         

pageoneresults

6:56 pm on Dec 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I've recently been pressed to find an alternative method of including content other than FP Includes which I've used for 10+ years. The change has to do with a bug in FP2003 (which I recently upgraded to from FP2002) in how it handles the code formatting of the include statements. Suffice it to say, I don't want to work in that environment if I can't have complete control over my code formatting.

FrontPage Includes

FP Includes function very similar to SSI (Server Side Includes). There is one major difference and that is the way the pages are developed. With FP, its a complete web page. With SSI, it is the content which is to be included into the destination page. It might contain a navigation div with list items, etc. Here's a previous topic on how FP Includes function...

Example of FrontPage Include Syntax...

<!--webbot bot="include" u-include="file.asp" tag="body" --> 

ASP Includes

Since I develop primarily in asp, my file extensions are in the .asp format. With .asp, I have two methods of including content.

Example of ASP Include Syntax

<!-- #include virtual="/file.asp" -->
<!-- #include file="file.asp" -->

I use the Virtual method exclusively due to the way I structure and organize included content.

The problem with asp includes is that they contain only the html code to be included in the destination page. I cannot view those pages at the browser level with all their proper formatting. They don't function like FP includes.

Server Side Includes

Then you have SSI (Server Side Includes) which I've seen many confusing topics on concerning the .shtml extension. Basically it comes down to this, if you are using SSI, you need to configure IIS to parse your .htm files as .shtml. Its a simple process as far as I can tell. SSI's function just like ASP includes.

Example of SSI Syntax

<!--#include file="/file.asp" -->

I've not investigated all of the methods available and was hoping that someone with more technical knowledge of this can correct me if I'm wrong in my above synopsis.

Is there an include method that functions just like FP's way? I mean, I'd like to browse to that include page and see it formatted just the way it should be once included into its destination page. Am I missing something here?

What other methods are available for including content? Please do provide code examples so that all reading can understand how to do this, including me! ;)

Bluesplinter

10:37 pm on Dec 28, 2005 (gmt 0)

10+ Year Member



I can tell you how to use CF includes, but I don't suppose that would help you much <g>.

However, I did want to warn you about one thing you need to be aware of if you decide to use SSI by telling IIS to process .html pages as .shtml... to do so will circumvent any .asp processing. IOW, IIS won't know to process the page first as .shtml, then to do it again as .asp. You basically get one pass through a script engine.

If that's not a concern, then never mind :) Also, since I've never actually tried the above, I'm only 99%+ positive about it ;)

Since you work in .asp, have you considered using asp.net? The 2.0 version uses a better (IMO) include method called "Master Pages".

jatar_k

10:42 pm on Dec 28, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



very nice post P1

apologies, I will just link to a thread from the PHP library that talks about it

A dynamic site in 2 minutes [webmasterworld.com]

it essentially deals with templating but this holds the essence of using includes with PHP

reference:
include [php.net]
include_once [php.net]
require [php.net]
require_once [php.net]

<edit>I guess I should add

if you use dreamweaver it will process these includes properly (I believe) and display the finished product in your fancy little WYSIWYG editor.

You don't necessarily have to have .php files to use php functionality, you can do the same thing you mentioned for .shtml and setup php parsing on any file extension you like. Though, as Bluesplinter mentioned, you can only parse any given extension for 1 scripting language. There are ways around this by using exec and the like in php, or even SSI for that matter, but these are not always an option for everyone. They have some unpredictable results.

[edited by: jatar_k at 10:47 pm (utc) on Dec. 28, 2005]

pageoneresults

10:46 pm on Dec 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



However, I did want to warn you about one thing you need to be aware of if you decide to use SSI by telling IIS to process .html pages as .shtml... to do so will circumvent any .asp processing.

I wondered about that, thanks for bringing it up. I've since decided that the ASP Virtual Include method is probably going to be my best alternative. I need to make some changes to my local system so it acts like a server and executes those includes while I'm in development mode.

I'd still like to see all of the other available methods for including content.

ASP.NET?

Wouldn't touch it with a 10 foot WYSIWYG stick. It is IE centric, it produces invalid code (uses quite a bit of proprietary tagging) and you can't work on it with a WYSIWYG editor, you need to use Visual Studio which I'm not familiar with. It is a programmer's dream and an html coders nightmare!

Bluesplinter

11:41 pm on Dec 28, 2005 (gmt 0)

10+ Year Member



Wouldn't touch it with a 10 foot WYSIWYG stick. It is IE centric, it produces invalid code

For 1.0 or 1.1, I'd agree with you, but I've had no trouble getting 2.0 to output the same validated code I'd use manually. The trick is to use it, not let it use you (IOW, write the code yourself, don't let Visual Studio write it for you). My usual MO is to create the page in Dreamweaver, then add the code as needed for the dynamic portions in VS. Doing it this way produces valid, browser independent code -- I'm a stickler for Web Standards, and use nothing browser-specific in the html.

But, I'm not a .net evangelist, so if you're happy with .asp includes, that's cool with me :) After all, I still use old Coldfusion code on some of my sites... if it ain't broke, etc.

Corey Bryant

3:26 pm on Jan 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The other option if you have Windows XP pro is to install ISS to parse the ASP pages to view the includes. My developer does this on his testing computer / server before he places everything on the server. I just publish everything and hope that it is all right.

I have thought about doing this but since I also use virtual links in my image paths I have gotten used to not seeing too much :)

-Corey