Page 1 of 1

navigation bar menu

Posted: Thu Feb 23, 2006 9:28 pm
by vietboy505
I want to write a navigation bar menu file that will place inside every php file. Is it possible to set all the navigation link on the left? Such as link.php

Code: Select all

Link 1 
Link 2 
Link 3
Then put a include function in every php file. Whenever, I feel like updating the links, I just change link.php and it will change the rest, it's kind like XML.

Posted: Thu Feb 23, 2006 10:01 pm
by nickman013
You can do somthing like this

links.php

Code: Select all

<a href=http://url>link 1</a>
<a href=http://url>link 2</a>
<a href=http://url>link 3</a>
<a href=http://url>link 4</a>
And on the pages that you want the menu on you can do this

Code: Select all

<div id=menu style"float:right;">
<? include('/path/to/links.php') ?>
</div>
Something like that?

That not be the best way but its one of the easiest.

Or you can put the links into a DB, and do it that way (probly easier).

Posted: Thu Feb 23, 2006 10:32 pm
by vietboy505
awesome.. that is what I needed.

what about putting a an log at the top right.

index.php

Code: Select all

<div id=menu style="float:left">
<? include('nav_link.php') ?>
</div>

<div id=logo style="float:top-right">
<? include('logo.php') ?>
</div>
logo.php

Code: Select all

<img src="images/logo.gif" alt="logo">
Some how the image show up but doesn't show the "logo" in the description and it's it's not to the right, it's in the left. How can it fix it? maybe float:top-right code is wrong?

Posted: Thu Feb 23, 2006 10:41 pm
by vietboy505
index.php

Code: Select all

<div id=menu style="float:left">
<? include('nav_link.php') ?>
</div>

<div id=logo style="float:top-right">
<? include('logo.php') ?>
</div>

<div id=copyright style="float:bottom">
<? include('copyright.php') ?>
</div>
I also added a copyright.php at the bottom, but all is munch into the top left. I guess there is not much content to fil up. But is there a way to set exact at the bottom regardless of the content without using frame? Thanks!

Posted: Thu Feb 23, 2006 10:43 pm
by nickman013
I think the CSS code for floating to the top right would be this.

Code: Select all

<img src="image.jpg" style="float:top; float:right;">
Somebody correct me if I am wrong.

Posted: Thu Feb 23, 2006 10:44 pm
by nickman013
After your style attributes you need to end them off with a ; (simi-colon) .

Posted: Thu Feb 23, 2006 10:49 pm
by feyd
the last css attribute does not need to end with a semicolon, however, inlining style information usually isn't the best way of doing it. That's what classes and id's are for.

Posted: Thu Feb 23, 2006 11:15 pm
by vietboy505
awesome.. now my logo is in top right..

but my copyright.php is still top even though I use:

Code: Select all

<div id=copyright style="float:bottom; float:center">
<? include('copyright.php') ?>
</div>
Also, can I combine logo.php & copyright.php into a file? This way I don't have to embed two divs for each .php.
Don't know how would this work since the link & image will be at different position.

Posted: Thu Feb 23, 2006 11:24 pm
by nickman013
change

Code: Select all

<div id=copyright style="float:bottom; float:center"> 
<? include('copyright.php') ?> 
</div>
to

Code: Select all

<div id=copyright style="float:bottom; align:center"> 
<? include('copyright.php') ?> 
</div>
I dont know about the second part. I think you can set up an array like this

Code: Select all

$pages = array (
		"logo" => "logo.php contents",
		"image" => "image.php contents",
                        )"
Any when you want to echo one of them you would do this

Code: Select all

echo $pages['logo'];

//or

echo $pages['image'];
I think.

Posted: Thu Feb 23, 2006 11:35 pm
by vietboy505
nickman013,

the align style doesn't work.. it just stay at the same place

Posted: Thu Feb 23, 2006 11:54 pm
by nickman013
I dont know then.