Setting up a Dynamic Root Structure Link Bar

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
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Setting up a Dynamic Root Structure Link Bar

Post by NewfieBilko »

What I mean is like what you can see on this site.

DevNetwork Forums-> Forum Index -> PHP- Code -> This post


i was wondering the best logical way to approach this with a simplair site then this. Say I have 5-6 pages, and each of those pages go on to a selection of 4 pages each. How can I have 1 top_bar include that would go:

Home -> Page 1 -> Selection 4.....

Setting up varabiles for each of these sections then making true if it is on that page that session? I'd like to know others opinions on approaching this problem.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Each hyperlink contains a command and some command parameters. In order to define hyperlinks, just grab any variable parameters from wherever they are stored. In the forums example, that'll be a JOIN query: each topic is a member of a board which is a member of a forum.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Breadcrumb navigation can also, as McGruff implied, reflect the physical structure of your filesystem if you set it up that way. In the interest of user-friendly (i.e. short) URLs this is not the most common practice, though.
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

this requires setting all my url structures into a database then
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

im not sure if i understand. Does anyone have any ideas on the best way to go about implimenting a navagation bar like this one into a site:


Image


Ok, i dont mean to confuse, i just need a dynamic system for rooting where the enduser is, so he/she can move back through the steps it took to get there. Whats the best way to approach this problem when you already have a hard coded, smarty PHP system in production?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

How about a cookie? Every time someone goes to a page, you modify the cookie to be updated with the page they are on. For example. If someone goes to your index.php page, set the cookie to "index.php". From there they click a link to admin.php. On that admin.php page, you modify the cookie to be "index.php|admin.php", and so on. Then you can parse the cookie and make that link structure you want.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

database.

table structure similar to:
pages table
pageid int(10) unsigned not null auto_increment,
parentid in(10) unsigned not null,
urlid int(10) unsigned not null

url table
urlid int(10) unsigned not null auto_increment,
url varchar(255) not null,
urltext varchar(100) not null


then use mysql's internal looping (if possible) to grab each of the parents until the parentid is 0..
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

hmmm, both of you seem to have alright ideas.. hmmmmm, interesting.. something to think about.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Pickle's idea will allow a user to backtrace which pages they've visited on a site - the more someone would navigate, the longer the breadcrumb-navigation would be.

Feyd's idea is more feasible as it presupposes a fixed site-structure.
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

Yea im gonna try the database way. Considering everything else will eventually be put into databases for my site I might as welll have this.

So i drew up the 2 new tables. Im gonna fool around with them both a bit now, entering the page information. Then work on getting it called the right way.
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

my primary key/foriegn key, they will link the urlid's
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

i wanted 111 posts, thx
Post Reply