Web Hosting Talk







View Full Version : Sidebar? include code? Help please!


gamer1888
03-21-2004, 06:37 AM
I am re-designing my website. I am not some very good web designer so I do it in plain html. This time, I have gotten into a problem. I want to have a sidebar menu for all my pages. But I want it to be in some sort of "include" method so that when I edit the sidebar menu page, all others get updated automatically.

I have done this for the header and footer but I don't know how to do it for the sidebar. Can anyone help me out? Please!

gamer1888
03-21-2004, 08:32 AM
come on guys... it must be a piece of cake for u guys.... please let me know about it ASAP

tensixteen64
03-21-2004, 09:06 AM
Do you mean this?

<div id="sidebar">
<?php include("/path/to/your/sidebar.php"); ?>
</div>

gamer1888
03-21-2004, 09:37 AM
is dat in html or php?
i want an html code...

tensixteen64
03-21-2004, 09:39 AM
It's for a php include, but you can use it in an html document. :)

gamer1888
03-21-2004, 09:58 AM
oh thanks... can you please tell me the html include one? If you don't know it, I'll try figuring this out but if you do, please let me know because this one is a bit confusing

tensixteen64
03-21-2004, 11:35 AM
Sure, first make your sidebar.php file in a .txt (Notepad) file. Then, put the following in your .html document where you want the sidebar.php to show up:
<?php include("/path/to/your/sidebar.php"); ?>

Where it says /path/to/your/ use the absolute path such as

/home/username/public_html

This will only work if your host supports PHP though. :)

Corey Bryant
03-21-2004, 12:47 PM
You also might consider SSI - server side includes. You save your main page with SHTML or SHTM. This tells the server to parse this file before delivering it to the browsers. 99% of all hosts support SSI

More information:
http://www.bignosebird.com/ssi.shtml
http://www.smartwebby.com/web_site_design/server_side_includes.asp

gamer1888
03-22-2004, 08:14 AM
You mean I can code, etc my page in html put just rename it to .shtml or .shtm?

By the way, thanks a lot you guys. I have figured out how to do it now and yes, my server supports php and SSI both.

tensixteen64
03-22-2004, 09:27 AM
You are welcome...glad you have it figured out. :)