This is topic HTML Question in forum Books, Films, Food and Culture at Hatrack River Forum.


To visit this topic, use this URL:
http://www.hatrack.com/ubb/main/ultimatebb.php?ubb=get_topic;f=2;t=032501

Posted by Jay (Member # 5786) on :
 
Ok, trying to find something real quick. Want to set up a separate file for a section of a webpage home page. The idea is for this file to be separate so that it can be updated by others remotely. I know this is easy to do, but I’m not sure about some of the technical calls or wording. Not to mention I haven’t been doing much coding recently and even less web page development recently. Make sense what I’m asking for?
 
Posted by fugu13 (Member # 2859) on :
 
Look up Server Side Includes in the Apache HTTP Server documentation.
 
Posted by Chaz_King (Member # 3184) on :
 
ASP or PHP? If you are using apache then I am going to assume you have PHP functionality and I would go the route of a PHP include.

If you don't want to mess with either, you can always use an Iframe and have it reference the .html file, but Iframes are really not very good practice.
 
Posted by TomDavidson (Member # 124) on :
 
*nod* What you want to do is called a Server-Side Include. It's fairly simple, and there are a few ways to do it.
 
Posted by Chris Bridges (Member # 1138) on :
 
Server Side Includes (SSI) will work on UNIX or Windows-based servers, they're easy to set up, and very easy to maintain. It's essentially a text file. Includes can end in .txt, .sht, .htm, but I usually use .inc to make them easier to keep track of.

Whatever code you want to appear on all of your pages, place it in this text file. Just the code, don't use HTML head or body tags. I'll generally design the page to look the way I want it and then select and cut the section that needs to be an include and paste it into the text file. Save it somewhere you can find it easily, and then stick an include call wherever you want that code to appear. Say you saved a web page menu in an include called menu.inc. You'd place this:

code:
<!--#include virtual="menu.inc"-->

From then on, whenever you change that include, it will change immediately on all the pages that use it.

If files in different folders use the same include, it helps to place them in a separate folder to make them easier to find. I save mine in a folder called "includes" and use this:
code:
<!--#include virtual="/include/menu.inc"-->

Using a slash at the beginning of a relative URL (one without the full http://www.etc address) tells the server to start looking at the root and work down, so pages at /articles/2005/news/tuesday can use the same include code as pages in /sports.

Any web page that ends in .shtml can use includes. Pages ending in .htm or .html can also use them, but you need to adjust some server settings or add a file called .htaccess to your root directory that defines what pages can use includes.

[ March 09, 2005, 12:57 PM: Message edited by: Chris Bridges ]
 
Posted by fugu13 (Member # 2859) on :
 
There's some minor debate over best practices on naming SSIs, specifically the suffix. Its less important than with PHP or other programming includes, as a server side include is just a bit of text.

.inc should be fine, as Chris suggests, or .inc.html (so the filetype is indicated by the name).

Using something other than those or a slight variant could confuse a future maintainer.
 
Posted by Chris Bridges (Member # 1138) on :
 
Inc works better for me because no other file is likely to use that extension, and if I need to find it amongst others I can sort by file type and find 'em right off.
 
Posted by fugu13 (Member # 2859) on :
 
Yeah, I've never got that problem because I use the command line pretty much exclusively for dealing with web application/web site files, but if you use the GUI it could be a minor inconvenience.

mmmmm, wildcards . . .
 
Posted by fugu13 (Member # 2859) on :
 
as a side remark, I just realized it wouldn't be a problem for me if I used the GUI on OS X, either, as in the upper right corner there's a search box which does very fast local searches easily; I'd just go up there and type .inc.html, hit enter, and be done.
 
Posted by Jay (Member # 5786) on :
 
Cool. Thanks everyone. Looks like this will do it perfectly.
 


Copyright © 2008 Hatrack River Enterprises Inc. All rights reserved.
Reproduction in whole or in part without permission is prohibited.


Powered by Infopop Corporation
UBB.classic™ 6.7.2