navigation bar menu

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vietboy505
Forum Commoner
Posts: 53
Joined: Wed Feb 22, 2006 9:30 am

navigation bar menu

Post 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.
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post 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).
Last edited by nickman013 on Thu Feb 23, 2006 10:45 pm, edited 1 time in total.
vietboy505
Forum Commoner
Posts: 53
Joined: Wed Feb 22, 2006 9:30 am

Post 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?
vietboy505
Forum Commoner
Posts: 53
Joined: Wed Feb 22, 2006 9:30 am

Post 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!
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post 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.
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

After your style attributes you need to end them off with a ; (simi-colon) .
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
vietboy505
Forum Commoner
Posts: 53
Joined: Wed Feb 22, 2006 9:30 am

Post 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.
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post 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.
vietboy505
Forum Commoner
Posts: 53
Joined: Wed Feb 22, 2006 9:30 am

Post by vietboy505 »

nickman013,

the align style doesn't work.. it just stay at the same place
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

I dont know then.
Post Reply