navigation menu in xhtml and php same

Associate
Joined
7 Nov 2004
Posts
1,755
Location
Southampton/Oxford
Hi there guys, am stumped in how to make my navigation menu appear in all my pages, so I just change one file instead of going through all the pages to update the links and such? I'm using PHP and xhtml fyi

Thanks all
 
It should be a simple line you use in each of your pages. Depending on what your PHP menu filename is, of course, just use this code in the proper location on your pages:

Code:
<!--#include virtual="menubar.php" -->
 
<div id="navcontainer">
<ul id="navlist">
<li id="active"><a href="index.html" id="current">Home &larr;</a></li>
<li><a class="plain" href="signup.html"> Sign up here &rarr;</a></li>
</ul>
</div>

This is what I need on all the pages, now I've read I need to set all the .html pages to .php, then include


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

Which is reading from my require.php, so afterwards, my page looks like-

<div id="navcontainer">
<ul id="navlist">
<?php include("menu.php"); ?>

</div>

but the navigation bar disappears :confused:
 
I've got a basic website ready for work which makes use of the php include() method, which is a godsend. :) The code below is my index.php page which "includes" a header, menu (bar) and footer from separate PHP files. I hope it shows how it works. I have this working so this code functions as it should if you want to borrow/adapt it.

Code:
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en">
<head>
<title>My PHP include() page</title>
<link rel="stylesheet" type="text/css" href="default.css" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script src="css_browser_selector.js" type="text/javascript"></script>
</head>
<body>
<div id="wrapper">
<div id="header">
<?php include("header.php"); ?>
</div>
<div id="menu">
<?php include("menu.php"); ?>
</div>
<div id="content">
<p>Welcome to our new site. We hope you like the dropdown menus above.</p>
</div>
<div id="footer">
<?php include("footer.php"); ?>
</div>
</div>
</body>
</html>
 
Back
Top Bottom