Forum Moderators: phranque

Message Too Old, No Replies

How to put same content on all pages

using css, possible?

         

JTrollerb

5:27 am on Jul 9, 2004 (gmt 0)

10+ Year Member



Just like most websites, I'd like to put my navigation menu/header on the top of every page on my website, but I want to put in a file so that all the pages refer to that one file, so all I have to do is edit that one file and the change will be seen on all pages. Any help would be appreciated.

Thank you

edit_g

5:40 am on Jul 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll need to do this with some kind of server side include. Dreamweaver will let you do this with templates as well, I think, but it is easier with an include. Any programing language can be used (coldfusion, php, java, asp etc) or you could just call your pages .shtml and include it in your header.

Google: [google.com...]

I'm not too clued in on this, but other members will be able to fill you in on the details. There's also some good tutorials in the search.

dhaliwal

6:14 am on Jul 9, 2004 (gmt 0)

10+ Year Member



if you use asp, then you can include a file named menu.asp with just this simple code

<!-- #INCLUDE FILE="menu.asp" -->

but do keep the both files, i mean the file in which you need the menu and menu.asp in same directory.

coho75

1:32 pm on Jul 9, 2004 (gmt 0)

10+ Year Member



If you use PHP then all you need to do to include a file is put the following in your HTML code.

<?php
include "page.html";
?>

coho75

JTrollerb

7:52 pm on Jul 9, 2004 (gmt 0)

10+ Year Member



I tried out coho's method, and it's easiest. Now I noticed that by doing the PHP method, the extension of all my webpages must end in .php. Is that ok for all my webpages on my website to have that extension? And will this take up extra bandwidth or anything like that on my server?

Thank you

henry0

8:08 pm on Jul 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Beware of any kind of includes if you use the same include in folders set at other relative location
like ../../
Why: if you use any img you wil need to also bring an full set of image at the same level or use a WWW path.

coho75

8:23 pm on Jul 9, 2004 (gmt 0)

10+ Year Member



There is no need to switch all of your pages to a .php extension if you pages are hosted on an Apache server. Simply add the following to your .htaccess file.

AddHandler php-script .php .htm .html
AddType text/html .php .htm .html

This will tell the server to treat all .html pages as if they were .php. This will save you a load of time since you will not have to go through and change all the file names.

coho75

JTrollerb

12:33 am on Jul 10, 2004 (gmt 0)

10+ Year Member



coho, I added that code directly to my .htaccess file as you instructed, but did not work. I can view my php file (wwWebmasterWorldebsite.com/header.php), but when I go to the test page that includes the php include code you gave me, I see nothing. What could be causing this? Do I need to add the php/html code you gave me in your last post to a particular part of my .htaccess code?

Your help is appreciated.!

vkaryl

12:53 am on Jul 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've migrated most of the pages on all the sites I design/run to .php extensions. I don't notice that it makes any difference at all....

moltar

12:55 am on Jul 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In Apache [httpd.apache.org] you can do:

<!--#include virtual="/path/to/file.html" -->

JTrollerb

1:25 am on Jul 10, 2004 (gmt 0)

10+ Year Member



moltar, I tried using that code too (yes, I do have apache) but the page just appeared blank.

vkaryl

1:31 am on Jul 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Some (perhaps even MANY) hosts disallow includes (SSI), even the use of "virtual" as stated above. Which is why php includes are better and fairly painless. Every host I've ever been with allows .php....

JTrollerb

1:46 am on Jul 10, 2004 (gmt 0)

10+ Year Member



So I guess I'll just have to rename all my pages with the .php extension, huh?

And theres no disadvantages/setbacks of using php extensions whatsoever?

JTrollerb

3:35 am on Jul 10, 2004 (gmt 0)

10+ Year Member



And what about my main homepage? The entire address is wwWebmasterWorldebsite.com. If I renamed it to .php, wouldnt that mess it all up?

Thank you

coho75

3:55 am on Jul 10, 2004 (gmt 0)

10+ Year Member



Sorry JTrollerb, I think I may have given you the wrong code for the htaccess file. Been kind of busy lately. Try this, I just took it directly from my own htaccess file.

AddType application/x-httpd-php htm
AddType application/x-httpd-php html

That should do the trick. Sorry I didn't get back to you sooner. Hope that this helps.

coho75

JTrollerb

4:42 am on Jul 12, 2004 (gmt 0)

10+ Year Member



Even adding that code entirely messed up my website..just got a whole bunch of weird code. So I took it off and just renamed all my .htm files to .php and now it works.

Thank you!