Forum Moderators: buckworks

Message Too Old, No Replies

Header Template?

Create a header template

         

Bo_Dill

5:07 pm on Aug 18, 2008 (gmt 0)

10+ Year Member



There is probably an easy way to do this, but I can't find it!

I want to create a page header with my logo and a horizontal navigation bar (with drop down menus), and not have to copy the entire code into every page of my site. That way, if the ten or twelve pages need to be changed, I could simply change the "Header". It seems to me that this could be done in a manner similar to an external style sheet, but I haven't been able to find information on how to do it.

I don't expect someone to write the code for me, just point me in the right direction, and I'll learn how to do it. So far, I'm not even sure what words to look for (header and template are in the indexes of my books, and they get millions of hits with google, but I haven't managed to get on the right track yet).

Any help would be appreciated,

Bo

akmac

7:52 pm on Aug 18, 2008 (gmt 0)

10+ Year Member



PHP Includes is what we use. What languages(s) are you using to develop the site?

Marshall

8:44 pm on Aug 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can also use .asp includes or .shtml pages. Depending on your server, it may be able to be configured to treat htm/html pages as .php or .shtml so you do not have to change the current page extensions and possibly lose any rankings.

Marshall

Bo_Dill

3:08 pm on Aug 19, 2008 (gmt 0)

10+ Year Member



First and foremost, thank you both. I believe that the PHP include is the way to go ("include" was the word I needed to learn). Unfortunately, I haven't been able to get it to work. I read the whole section in my PHP For Dummies, and the W3 tutorial, and spent several hours so far trying to get it to work in a couple of test pages.

Finally, I tried validating the code and got an error message saying "The tag name "?php" is not in the HTML Configuration". With that, I am trying to figure out what to do next (looking up "Configuration" in books, googling, W#, etc. etc.). I did try to download a php file (I think it was PHP.ini) from a W3 link, but it was a BZ2 file and Windows couldn't open it.

I just thought that since I have sincerely tried to do this without bothering you guys again, you might be able to tell me a little more about what I should do next.

Any help will be appreciated. By the way, I am basically writing HTML (4.01 transitional?) and my editor is HOMESITE.

Thanks again,

Bo

rocknbil

5:18 pm on Aug 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<opinion>
PHP is a robust scripting language. It is used to dynamically output data based on a variety of conditions.

Server Side Includes (.shtml) are a server-based technology designed to do precisely what you want to do - include files or program output within a static page.

Summary: Use the right tool for the job.
</opinion>

As for it not working, did you do a basic "hello world" script in PHP to make sure PHP is properly working on your server?

IMO, it would be much easier to learn SSI than a scripting language at this point. Try this:

Contents of include_me.txt:

<p>This is my included content. IF you see me, SSI's are working.</p>

Contents of test.shtml:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>SSI Test</title>
</head>
<body>
<h1>SSI Test</h1>
<p>You should see the contents of include_me.txt below:</p>
<!--#include file="include_me.txt" -->
</body>
</html>

Upload them to the same directory on your server and request test.shtml from your browser.

The .shtml extension is what tells the server to parse the file, looking for the include directives. If you don't like the idea of naming your files with the .shtml extension, ask your ISP to set your server configuration to parse all .html or .htm files for server-side includes.

Bo_Dill

3:31 pm on Aug 20, 2008 (gmt 0)

10+ Year Member



Thank you. To give you an idea of the value of your advice; after reading your replies I spent the last day and night reading about php, SSI, servers, scripts, and includes, etc. etc.. Almost none of these words are included in the indexes of my several books, and even the "W3" site connects me directly to a php tutorial when I searched for "SSI".

As of now, I have at least a couple of test pages working in SSI (I still haven't had any luck with php, but I'll worry about that later), and I will expand their usefulness as I go.

Again, thank you. Please let me take this opportunity to tell you that all my life, I have helped people with carpentry, electrical, plumbing, and automobile maintenance, to name a few. Now, however, as much as my friends would like to help me, they know nothing about computers. If I ever get good at this stuff, I will certainly "pay it forward", as it was put in one the replies to a problem a little while back. Basically, I am saying that I do not come to you guys out of laziness. I really try to figure the stuff out myself, and if I had anybody local to turn to, I would ask them for help first. Well, that's about it. I just want you to know that I am trying very hard at learning this stuff, and I sincerely appreciate your help.

Bo

rocknbil

5:38 pm on Aug 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One other bit on SSI's, since you have them working (cool. :-) )

If you want to store the included file in a directory NOT in the same directory as the included file:

test.shtml
/included_files/include_me.txt

Use the #include virtual directive instead:

<!--#include virtual="/included_files/include_me.txt" -->

Bo_Dill

7:36 pm on Aug 20, 2008 (gmt 0)

10+ Year Member



Thanks again,

Bo