FacebookTwitter
Hatrack River Forum   
my profile login | search | faq | forum home

  next oldest topic   next newest topic
» Hatrack River Forum » Active Forums » Books, Films, Food and Culture » HTML Question

   
Author Topic: HTML Question
Jay
Member
Member # 5786

 - posted      Profile for Jay   Email Jay         Edit/Delete Post 
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?
Posts: 2845 | Registered: Oct 2003  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
Look up Server Side Includes in the Apache HTTP Server documentation.
Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Chaz_King
Member
Member # 3184

 - posted      Profile for Chaz_King   Email Chaz_King         Edit/Delete Post 
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.

Posts: 232 | Registered: Mar 2002  |  IP: Logged | Report this post to a Moderator
TomDavidson
Member
Member # 124

 - posted      Profile for TomDavidson   Email TomDavidson         Edit/Delete Post 
*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.
Posts: 37449 | Registered: May 1999  |  IP: Logged | Report this post to a Moderator
Chris Bridges
Member
Member # 1138

 - posted      Profile for Chris Bridges   Email Chris Bridges         Edit/Delete Post 
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 ]

Posts: 7790 | Registered: Aug 2000  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
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.

Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Chris Bridges
Member
Member # 1138

 - posted      Profile for Chris Bridges   Email Chris Bridges         Edit/Delete Post 
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.
Posts: 7790 | Registered: Aug 2000  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
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 . . .

Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
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.
Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Jay
Member
Member # 5786

 - posted      Profile for Jay   Email Jay         Edit/Delete Post 
Cool. Thanks everyone. Looks like this will do it perfectly.
Posts: 2845 | Registered: Oct 2003  |  IP: Logged | Report this post to a Moderator
   

   Close Topic   Feature Topic   Move Topic   Delete Topic next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:


Contact Us | Hatrack River Home Page

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