Welcome to WebmasterWorld Guest from 54.167.177.207

Forum Moderators: incrediBILL

Creating Links one time for the whole site?

   
9:44 pm on Jun 23, 2008 (gmt 0)

5+ Year Member



I am coding a web page currently, how would I go about coding it in a manner that I don't have to cut and paste the navigation bar in every page?
10:25 pm on Jun 23, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use server side includes. One text file with the insertion of a bit of code and viola, your entire code is inserted and you have your navigation. This is also good for header and footer information

<!--#include virtual="/ssi/navbar.shtml" -->

From what I have learned, you are always supposed to save your pages with the .shtml extension. I have used them and I love them.

Also, create a directory for all your includes to be held in. If you use them for more then your navigation.

Hope this helps!

4~css!

11:24 pm on Jun 23, 2008 (gmt 0)

5+ Year Member



If you have php, you can use php includes in a very similar fashion

<?php include ("myIncludesDirectory/myNavBar.php"); ?>

Such a file like myNavBar.php would contain the EXACT same bits of html code and nothing else... i.e. for a navBar, just the links, no <head> or <body> tags, etc)

I think that a file like navbar.shtml would have to have the <head> and <body> tags...
maybe I'm wrong...

This is also good for header and footer information

The php approach (and maybe the .shtml approach, too?) is good for ANY repetitive data...

e.g. DOCTYPE and MIME type declarations (ought to be useful when HTML5 comes out)
meta tags in the <head>
etc
:)
4:34 pm on Jun 24, 2008 (gmt 0)

5+ Year Member



I think that a file like navbar.shtml would have to have the <head> and <body> tags...
maybe I'm wrong...

Maybe I'm wrong, but I don't use head and body tags in any of my ssi. I do just the same as php include - exact code and nothing else.
10:19 pm on Jun 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The file that you are creating as an include would just include the portion of the area that you are using. Such as the navigation.

What you would do is take the whole area of the list that you are using. If I have the list within a div, I just cut the information out of the div, put it into a text file and insert the ssi code. It is really easy to do.

You can always do a search on google for tutorials on this. There are a number of them out there that are really great to read.

10:46 pm on Jun 24, 2008 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Just to clarify, you can use SSI's to include ANY valid data - some useful examples -

- Plain text file (no headers required, a single word, even)

- output from a script or a compiled program (see SSI man. for exec directive). In this case, you must print content-type: text/html headers from your external program (or other valid content-types.)

- RSS/XML (but your document has to be a valid XML/XHTML doctype and you have to provide XML headers)

- image or other binary data

Basically anything you can output in a page you can include in the page using SSI. It doesn't have to be a valid HTML/XHTML document - in fact, doing so might screw up a perfectly valid document:

<html><head><title>Title</title><body>
<!-- below is my include, do the math! -->
<html><head><title>Include</title></head><body>
<p>Two plus Two.</p>
</body></html>
<!-- End of my include -->
</body></html>

The data you include becomes part of the page, so you just validate the entire .shtml with all the data imported.

In older server O.S's the use of SSI's presented serious security flaws and it was a memory hog (because it parses files before reading instead of straight serving) but it's no longer the case.

2:07 pm on Jun 27, 2008 (gmt 0)

5+ Year Member



If your using dreamweaver just use the template function. I can see the magic word here is "codeing" and to create that would be hard, but i found the template system quite useful and so much faster.
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month