|
Server Side Includes |
| How To Add
Static Content Into Web Pages by Str82u |
|
|
|
|
In this article, I'm
going to show you how to insert static (never changing) content from
another source into an existing page, such as a menu, to allow you to
have the same information on every page. It's called SSI (Server Side
Includes) and simply means you are adding a webpage from one place into
a spot in another webpage. The best example of this is a site's menu,
since you would want that to be the same on every page, but when you
edit your menu, you also want it to update on every page without having
to edit every single page in the website. We'll be using one of my
sites,
http://realfreesearches.net,
as the example. |
|
An Important Note,
while the pages are no different in any way to a normal webpage, the
extension to use is .shtml not htm or .html. When saving the page, ask
your program to "Save As", then type in the name of the page adding .shtml
to the end and that should automatically create it as an shtml webpage.
This is simple to do if you can't get your web design program to save it
in this format, after you finish with the page and close out of the
program, find the webpage, open it in a text editor and then save it as
"something.shtml", that's it, upload this and you have it. Another trick
to this is to open Windows Explorer, navigate to the files in the
website and it will show you the files with the present extension of
say, .html, just rename the file adding the S to html and move to the
next file. It's easier than using the text editor and leaves only one
page to deal with instead of two.
Here's what happens if you don't save it as an .shtml file
http://www.realfreesearches.net/ssi_example1.htm |
|
|
Another thing to note is
that you need to know is that while most servers have the capability to
do it, they don't all allow SSI for security reasons. If you can't find
it on your host's FAQ or HELP pages, email them. You can always try a
quick test by using simply made pages first. |
|
When I first
designed the site pages for realfreesearches.net, I built it just like
it would have been without includes, then when I was as satisfied as I
could be, I simply cut out the parts that were to be included and
created a new page with them. The original page with the missing part
then became the template for the rest of the site. From here, any global
changes will have to be by hand one page at a time, but I was fairly
certain that this was it, and since the parts that would be updated or
contain information that might change would be in the menu, or missing
area.
An example of just the page without the included material can be seen
here
http://www.realfreesearches.net/ssi_example2.shtml
Now that you have this template, go to the blank area and insert the
code into the html source of the page that is going to cause the
included material to appear. REMEMBER, you MUST add this code into the
html of the page, not on the page itself. |
|
The code to add an
included item to a page is <!--#include file="pagename.htm" -->
Change pagename to the name of your included content, it can
be .htm, .html, .shtml or .txt. |
|
|
Now, you save this as
template.shtml and continue to use this for every other page you make
that should have the menu on it. |
|
The content to be
included should generally be another web page, building it by keeping in
mind the size of the space that it's going to be in on the other pages.
In my case, it was the material I cut out from the original template.
An example of an actual included page can be seen here
http://www.realfreesearches.net/left.htm
From here, you can edit the material you want included in all the other
pages and once uploaded to your server, every page will show the changes
from just one edit instead of several. |
|
|
Well kiddies, that's about it, you should
be able to create many happy pages in this way and have the ability to
add whatever you want to the included content and have it on all your
pages at once without all the work of going through every page at your
site and making the edits, then worse still, changing you mind or
finding a mistake and having to go do it all over again. Hope I was able
to make something that was confusing a little simpler for you, if you
have any questions about this or other code related problems, find me in
the forum and I'll be glad to help.
Keep It Str8!
This and all
material contained within is copyrighted and may not be reproduced
without the express consent of the author and/or this site
|
|
|