Creating a simple Navigation bar

jeanm

Member
I've got three sites created in Frontpage and now I'm swapping over to Dreamweaver. I want to create a very simple Navigation bar and Footer bar for all three sites. Apart from the colour and the various links within, all three will be identical. As each site continues to grow I may need to add further links into both bars. How do I do this without having to open each page to adjust them manually?

In Frontpage I had code like so:

<!--webbot bot="Include" U-Include="travel-header.htm" TAG="BODY" startspan --> etc etc

and I just had to make changes to the Nav bar page and that solved the problem, but that is not usable in Dreamweaver is it? How do I solve this with CSS please? Please make the answers in simple terms.
 

smoovo

New Member
How to include page in PHP

Take a look in this page, maybe it's good for you.

Web developers use PHP based templates. If you have a page with code and you want it to be added to all of the pages, and while you changing it, it will affect all the pages, use PHP.

PHP:
<?php
    include("header.html");
?>

it's very similar to what you have with Frontpage. You just have to upload your shared page, and include it with the right path, that's it. :)
 

jeanm

Member
This is the code I'm using for my Navigation page which is saved as a .php:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>........................</title>
</head>

<body>


<a href="http://www.railway-train-travel.com.au/newpage.php">Newpage</a>|
<a href="http://www.railway-train-travel.com.au/newpage.php">Newpage</a>|
<a href="http://www.railway-train-travel.com.au/newpage.php">Newpage</a>|
<a href="http://www.railway-train-travel.com.au/newpage.php">Newpage</a>|
<a href="http://www.railway-train-travel.com.au/newpage.php">Newpage</a>



</body>
</html>



and this is what I'm using for my (say) Index page which is also saved as a .php:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>


<?php include("navigation.php"); ?>
<p>This is my Navigation page that uses a common navigation to save me time when I add
new pages to my website!</p>



</body>
</html>



There is a mistake somewhere because when I look at the design view for the Index page I'm getting the coding ..............</head> coming up before the various Navigation links.

I reckon I've got something wrong regarding the Title tag on the Navigation page but then I've read that you can't have a page minus its title tag if you are using xhtml. What have I done?
 

smoovo

New Member
Don't panic, you are using it as an iframe... It's not working like that. When you are including a file, the server write the code together with the file inside. So you got a page with beginning, "Doctype", "Title", etc., and after the body comes again the "Doctype", "Title",...

HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>


<!-- Your included file -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>........................</title>
</head>

<body>


<a href="http://www.railway-train-travel.com.au/newpage.php">Newpage</a>|
<a href="http://www.railway-train-travel.com.au/newpage.php">Newpage</a>|
<a href="http://www.railway-train-travel.com.au/newpage.php">Newpage</a>|
<a href="http://www.railway-train-travel.com.au/newpage.php">Newpage</a>|
<a href="http://www.railway-train-travel.com.au/newpage.php">Newpage</a>



</body>
</html>

<!-- End of included file -->


<p>This is my Navigation page that uses a common navigation to save me time when I add
new pages to my website!</p>



</body>
</html>

In your navigation file leave the code for the navigation only. This way the server will write the code and when it will get to the include function it will write only the navigation script into the page.

"navigation.php"
PHP:
<a href="http://www.railway-train-travel.com.au/newpage.php">Newpage</a>|
<a href="http://www.railway-train-travel.com.au/newpage.php">Newpage</a>|
<a href="http://www.railway-train-travel.com.au/newpage.php">Newpage</a>|
<a href="http://www.railway-train-travel.com.au/newpage.php">Newpage</a>|
<a href="http://www.railway-train-travel.com.au/newpage.php">Newpage</a>

- Enjoy. :)
 
Top