Menu

Status
This thread has been Locked and is not open to further replies. The original thread starter may use the Report button to request it be reopened but anyone else with a similar issue should start a New Thread. Watch our Welcome Guide to learn how to use this site.

tjb

Thread Starter
Joined
Jan 1, 2007
Messages
37
Is there a way to make a website menu so that I don't have to change it on every page every time I want to add something?
 
Joined
Apr 30, 2005
Messages
3,012
u could use a php include.

<?php include("menu.php");?>

then in a file called menu.php put ur menu there
 

tjb

Thread Starter
Joined
Jan 1, 2007
Messages
37
namenotfound said:
u could use a php include.

<?php include("menu.php");?>

then in a file called menu.php put ur menu there
I couldn't get it to work. Heres a sample page of my site layout

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>Website Powered by Bravenet</title>
    <link rel="stylesheet" type="text/css" href="green_b.css">
</head>
<body>
<div class="wrapper">
	<div class="title titlemargin">My Website</div>

    <div class="left" style="font-weight: bold; margin: 5px; height: 100%; width: 150px;" align="center">
		<div class="sidebaritem first"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
	</div>
	
	<div class="border content padleft" style="padding-right: 20px;">
		<p class="title2">Welcome to Your New Website</p>
      	<p>Welcome to your new home on the Net!  If you don't have your own Domain Name yet, you can get one through your Hosting Manager.  Also in your Hosting Manager, you can find handy tools to maintain and update your Web Site, such as our Java-based FTP Applet, an easy way to upload your files to the server.</p>
       	<p>From the Hosting Manager you will also find links to our Web-based File Manager which includes a Text Editor and Visual Editor, making Site maintenance easy. And don't forget to check out the <a href="http://www.bravenet.com/resources/index.php">Resource Area</a> for HTML help, scripts, clip art, audio clips, fonts, and more!</p>
       	<p class="title2">Adding Fun Tools to Your Site</p>
       	<p>Through your Bravenet Account, you can choose many of our FREE Tools to enhance your Site.  Add as many as you like!  Get a Hit Counter, Guestbook, Message Board, Email Form, Minipoll, Web Journal, or any of Bravenet's other great <a href="http://www.bravenet.com/webtools/index.php">Tools and Services</a> to make your Site fun and interactive.</p>
     
	</div>
	<br style="clear: both;" />
	<div class="border footer"><a href="http://www.bravenet.com">Powered by Bravenet.com</a></div>
</div>
</body>
</html>
 
Joined
Mar 14, 2006
Messages
941
the file that has the menu has to be a .php file, it won't work if it's .htm or .html
 

tjb

Thread Starter
Joined
Jan 1, 2007
Messages
37
so would I just take this part out

Code:
 <div class="left" style="font-weight: bold; margin: 5px; height: 100%; width: 150px;" align="center">
		<div class="sidebaritem first"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
and save as a "menu.php"
and put this were the menu used to be

Code:
<?php include("menu.php");?>
 
Joined
Apr 30, 2005
Messages
3,012
yes, so it would be like this:

PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>Website Powered by Bravenet</title>
    <link rel="stylesheet" type="text/css" href="green_b.css">
</head>
<body>
<div class="wrapper">
	<div class="title titlemargin">My Website</div>


  <?php include("menu.php");?>
	
	<div class="border content padleft" style="padding-right: 20px;">
		<p class="title2">Welcome to Your New Website</p>
      	<p>Welcome to your new home on the Net!  If you don't have your own Domain Name yet, you can get one through your Hosting Manager.  Also in your Hosting Manager, you can find handy tools to maintain and update your Web Site, such as our Java-based FTP Applet, an easy way to upload your files to the server.</p>
       	<p>From the Hosting Manager you will also find links to our Web-based File Manager which includes a Text Editor and Visual Editor, making Site maintenance easy. And don't forget to check out the <a href="http://www.bravenet.com/resources/index.php">Resource Area</a> for HTML help, scripts, clip art, audio clips, fonts, and more!</p>
       	<p class="title2">Adding Fun Tools to Your Site</p>
       	<p>Through your Bravenet Account, you can choose many of our FREE Tools to enhance your Site.  Add as many as you like!  Get a Hit Counter, Guestbook, Message Board, Email Form, Minipoll, Web Journal, or any of Bravenet's other great <a href="http://www.bravenet.com/webtools/index.php">Tools and Services</a> to make your Site fun and interactive.</p>
     
	</div>
	<br style="clear: both;" />
	<div class="border footer"><a href="http://www.bravenet.com">Powered by Bravenet.com</a></div>
</div>
</body>
</html>
and in menu.php have this:

HTML:
 <div class="left" style="font-weight: bold; margin: 5px; height: 100%; width: 150px;" align="center">
		<div class="sidebaritem first"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
		<div class="sidebaritem"><a href="">menu item</a></div>
</div>
 
Joined
Dec 22, 2004
Messages
721
Hi tjb,

Namenotfound's solution should work fine.

Is the path to the menu.php file correct? That is, if the menu.php file is sitting in the same folder as the other file, then the path is correct. If you have put the menu.php file into another folder such as includes, for instance, then the path to the menu.php file will have to reflect that.

Have tested the solution on my test server and it works correctly.

Hope this helps.
 

tjb

Thread Starter
Joined
Jan 1, 2007
Messages
37
deepdiver01 said:
Hi tjb,

Namenotfound's solution should work fine.

Is the path to the menu.php file correct? That is, if the menu.php file is sitting in the same folder as the other file, then the path is correct. If you have put the menu.php file into another folder such as includes, for instance, then the path to the menu.php file will have to reflect that.

Have tested the solution on my test server and it works correctly.

Hope this helps.
It's still not working. I have copyed and pasted the same codes that he posted and got nothing. Is there something I'm missing?
 
Joined
Feb 28, 2005
Messages
609
If your testing locally do you have PHP installed? Or on your web server?
 

tjb

Thread Starter
Joined
Jan 1, 2007
Messages
37
Gibbs said:
If your testing locally do you have PHP installed? Or on your web server?
How would I know if I had PHP installed. I am uploading .htm files on to google pages
 
Joined
Feb 28, 2005
Messages
609
tjb said:
How would I know if I had PHP installed.
Create an empty text file called "test.php" with just have the following in it:
PHP:
<?php
phpinfo();
?>
Save it (as test.php), upload it and view it.
tjb said:
I am uploading .htm files on to google pages
If your going to use an include you must save BOTH pages as .php.
 

tjb

Thread Starter
Joined
Jan 1, 2007
Messages
37
Gibbs said:
Create an empty text file called "test.php" with just have the following in it:
PHP:
<?php
phpinfo();
?>
Save it (as test.php), upload it and view it.
I uploaded test.php and tryed to open it and it wanted me to save it to my computer.
Gibbs said:
If your going to use an include you must save BOTH pages as .php.
Do you mean save the pages as PHP files?
 
Joined
Feb 28, 2005
Messages
609
tjb said:
I uploaded test.php and tryed to open it and it wanted me to save it to my computer.
Doubt the server runs PHP then... Try see if you can view your hosting plan (specifications) and see if you have any server-side langauges installed.

tjb said:
Do you mean save the pages as PHP files?
Yes. If you want to use PHP you have to save them as PHP files (both of them).
 
Joined
Apr 30, 2005
Messages
3,012
I'm not sure if google pages even has PHP.

Do you know if it supports basic SSI?

<!--#include file="menu.html"--> and save the page as .shtml

But not sure if they even have that, it's worth a try though.
 
Status
This thread has been Locked and is not open to further replies. The original thread starter may use the Report button to request it be reopened but anyone else with a similar issue should start a New Thread. Watch our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top