Need help with include files

Discussion in 'HTML & Website Design' started by 71Corvette, Jan 29, 2009.

  1. #1
    Hey all,

    I need a bit of help. I'm trying to develop some include files for my website, but I'm having a hard time getting them to work. The overall process seems relatively simple, but every article I read provides a different set of instructions on how to accomplish this.

    Given the fact that I have no formal training in web design I thought I'd turn here for some help. I prefer to keep .htm extensions on my website and I believe I'll need to make some edits to my .htaccess file. I tried a few suggested snippets of code last night to no avail.

    Can someone provide some advice? I'm working with a basic html website hoted on a Linux server. If it helps, I could post the contents of my .htaccess file

    Thanks in advance!
     
    71Corvette, Jan 29, 2009 IP
  2. mmerlinn

    mmerlinn Prominent Member

    Messages:
    3,197
    Likes Received:
    819
    Best Answers:
    7
    Trophy Points:
    320
    #2
    You will need to be more specific before anyone can help you. Like are you talking server side or client side include files? If server side, what are you using server side? PHP? Or? If client side, are they javascript files or what? Exactly what do you have available and exactly what do you need to do?
     
    mmerlinn, Jan 30, 2009 IP
  3. 71Corvette

    71Corvette Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Ok, so here's where my lack of formal training will probably show a bit...

    I believe I'm looking for server side includes. I have a paid hosting account and upload my entire website to a file server. I plan to place the include files in a folder on that server. However, I'm open to suggestions.

    My website runs on basic html files, but my webhost does allow php, asp, etc. I checked and my webhost does allow SSI. Again, I'm open to suggestions on which is the best to use.

    Thanks again.
     
    71Corvette, Jan 30, 2009 IP
  4. mmerlinn

    mmerlinn Prominent Member

    Messages:
    3,197
    Likes Received:
    819
    Best Answers:
    7
    Trophy Points:
    320
    #4
    I think the first thing that you should do is to do a thorough analysis of what "server side" and what "client side" mean in relationship to programming. From what I see in your last post I think (but do not know) that you are very fuzzy on what each of them mean.
     
    mmerlinn, Jan 30, 2009 IP
  5. Website Design Perth

    Website Design Perth Peon

    Messages:
    66
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    My 2c.

    1) There's no particular reason to keep .htm extension. I use .php a lot and remove the extension via htaccess:

    Options +FollowSymlinks
    
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php
    Code (markup):
    ** Remember all links should not include file extensions:

    <a href="about-us">About Us</a>
    Code (markup):
     
    Website Design Perth, Jan 31, 2009 IP
  6. Website Design Perth

    Website Design Perth Peon

    Messages:
    66
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Whoops. And then insert snippets like a common header or footer like this into body:

    <?php include_once('includes/header.php'); ?>
    Code (markup):
     
    Website Design Perth, Jan 31, 2009 IP
  7. old_expat

    old_expat Peon

    Messages:
    188
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I use SSI (server side includes) on all my sites. Headers, footers, navigation, Google ads, etc. I usually have a folder named 'inc' where I load all my includes.

    The reason I use a folder for the includes is partly housekeeping, but it also allows me to disallow that folder in my 'robots.txt' file Includes can have any extension you want. For HTML pages (non-PHP), I normally use files like 'head.html', 'foot.html', etc

    When I want to call an include, I use

    <!--#include virtual="/inc/head.html" -->
    Code (markup):
    SSI also allow you to do some neat stuff with dates. One example is an automatic update on your copyright notice. There is some good stuff on the Apache site.

    http://httpd.apache.org/docs/1.3/howto/ssi.html
     
    old_expat, Jan 31, 2009 IP
  8. cscott5288

    cscott5288 Active Member

    Messages:
    912
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #8
    I recommend you read this about server side includes.

    You can tell your server to parse .htm files by adding this into the .htacess file:

    AddType text/html .htm
    AddHandler server-parsed .htm
    Options +Includes
     
    cscott5288, Jan 31, 2009 IP
  9. smartsites

    smartsites Peon

    Messages:
    79
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Look at a cms app that has this functionality already built in. It's easier to manage.
     
    smartsites, Feb 2, 2009 IP
  10. 71Corvette

    71Corvette Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Thanks for the advice everone. I'm going to do a bit more research into this topic since, like most things I've experienced with web design, there are dozens of different ways to accomplish the same goal - each with varying pro's and con's. I only want to do this once, so I want to be sure what I pick is the best way. I suspect I'll be back in a few days, but you guys have provided some great leads for me to chase down and play with. Thanks!
     
    71Corvette, Feb 2, 2009 IP