SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Sep 2002
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Using 'include files' in html

    Hi

    I'm not sure if I'm in the right forum section, but I'm trying to get my include file to work in html. The site is completely formatted in CSS styles and I wonder if this would have any effect.

    here's what I've got included in my html page:

    <!--#include Include File="contents.html"-->
    <p> <a href="important-to-get-it-right.html">Why is it important to get this right?</a> |
    <a href="key-principles.html">Key principles</a> |
    <a href="good-practice-checklist.html">Good Practice checklist</a> |
    <a href="how-to-guides.html">'How to' guides</a> |
    <a href="case-studies.html">Case studies</a> |
    <a href="samples-templates.html">Samples and templates</a> |
    </p>
    <!--/#include"-->

    However, I was hoping all I had to insert into the html page was:
    <!--#include Include File="contents.html"-->

    Can someone please assist as I am now very lost...
    thanks so much
    Felicia

  2. #2
    American't awestmoreland's Avatar
    Join Date
    Sep 2002
    Location
    Grand Rapids, MI
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Felicia,

    I'm not sure from your post what problems you're getting when attempting to display your page, but it's probably worth stating some basics to check. Apologies if you've already checked this stuff:

    If you're using an Apache web server, then there are some settings that you need to ensure are configured before it will interpret Server Side Includes (SSIs).

    The following link will tell you what you should check:
    Configuring your server to permit SSI

    You'll notice that there is code at that link which tells the server which file extensions it should parsed for SSI directives. In the case below, the server is expecting files of type ".shtml" (I think that's the usual standard):

    AddType text/html .shtml
    AddHandler server-parsed .shtml
    If your server is already configured in this way, then you need to ensure that the file containing your <!--#include Include File="contents.html"--> has an .shtml extension.

    Furthermore, you should appreciate that all an include of the type that you're using will do is to include another the contents of the specified file literally into your .shtml file as though you had pasted it in manually.

    The following quote from this page probably explains this better:

    <!--#include file="myfile.htm"-->
    Put that anywhere in your webpage, and myfile.htm shows up in it's place. The file doesn't have to be a ".htm" file. It could also be a ".txt" file (ie: myfile.txt). So how is this useful? Let's say you have a peice of content that is repeated on many pages of your site (a navigational bar, for example). By saving that content as an individual html file, and using SSI instead to include that content onto those pages, updating that content becomes merely changing that ONE file. The changes is instantly reflected on all pages containing the SSI include command.
    If you want to use an SSI to specify a stylesheet, then the way to do it would probably be to have a header.txt file containing everything from the <html> tag down to the <title> tag and specifying the .css file in the process.

    e.g.
    header.txt
    <HTML>
    <HEAD>
    <LINK href="mystyle.css" rel="stylesheet" type="text/css">
    <TITLE>
    Your .shtml file would then look something like this:
    <!--#include Include File="header.txt"-->
    This is the title of my page
    </TITLE>
    </HEAD>
    <BODY>
    ...rest of the page content...
    </BODY>
    </HTML>

    I've just previewed this response and realised that it's probably as clear as mud

    If this doesn't help, then let me know and I'll see what I can come up with.


    Andy


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •