niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » PHP
idea/ concept behind creating breadcrumbs
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
Author Message
crescent_au@yahoo.com
*nix forums beginner


Joined: 21 Nov 2005
Posts: 6

PostPosted: Fri Jul 21, 2006 12:10 am    Post subject: idea/ concept behind creating breadcrumbs Reply with quote

Hi everybody,

I want to create dynamic breadcrumbs for a site I am developing. I just
want to get some views about the algorithm of breadcrumbs.

The way I look at it is the concept of parent/ child (main/ sub). I
have the "Home" page, which has links to sub-pages such as
"Introduction", "History", "Timetable", etc. Each page can have other
sub-pages, such as "Timetable" can have "Semester1", "Semester2", etc.
This is how I'd initially think. Am I on the right track? If yes, how
do I proceed? Do I need a database or is there another efficient way to
do it? If it is in fact the way I am thinking, then I think I need a
way to "register" or hold the data in some way and access it on each
page. I'm just lost here.

Please push me to the right direction.

Thanks
Ben
Back to top
flamer
*nix forums beginner


Joined: 06 Jul 2006
Posts: 36

PostPosted: Fri Jul 21, 2006 12:18 am    Post subject: Re: idea/ concept behind creating breadcrumbs Reply with quote

crescent...@yahoo.com wrote:

Quote:
Hi everybody,

I want to create dynamic breadcrumbs for a site I am developing. I just
want to get some views about the algorithm of breadcrumbs.

The way I look at it is the concept of parent/ child (main/ sub). I
have the "Home" page, which has links to sub-pages such as
"Introduction", "History", "Timetable", etc. Each page can have other
sub-pages, such as "Timetable" can have "Semester1", "Semester2", etc.
This is how I'd initially think. Am I on the right track? If yes, how
do I proceed? Do I need a database or is there another efficient way to
do it? If it is in fact the way I am thinking, then I think I need a
way to "register" or hold the data in some way and access it on each
page. I'm just lost here.

Please push me to the right direction.

Thanks
Ben

Hi, you can use _GET for this, easiet way is like
index.php?cat=$cat&sub=$sub&id=$id for as many depths as needed, you
just need to make sure each link on your page adds/removes the required
strings. you could use numbers or names, i use names in mine so i dont
need to have a database and i can capatilise the first letter of the
word and remove underscores ect so it tidies it up when display the
breadcrumbs.

Flamer.
Back to top
rlee0001
*nix forums addict


Joined: 11 Jan 2006
Posts: 53

PostPosted: Fri Jul 21, 2006 2:18 am    Post subject: Re: idea/ concept behind creating breadcrumbs Reply with quote

Well if you have a database then that would be a good place to start.
If you are not currently using a database you could store the
relationships in an include file and include_once it into each page.

For a database I would do something like:

"id","pagename","parent_id"
1,"Home",0
2,"Introduction",1
3,"History",1
4,"Timetable",1
5,"Semester1",4
6,"Semester2",4
....

Then use a recursive function to "walk" up and down the tree:

function printnode($node) {
if ($node->parent_id) {
printnode(getNode($node->parent_id));
}
echo $node->pagename;
return;
}

This is an oversimplification obviously but you get the idea. The page
needs to call printnode(getNode(PAGE ID)) to print it's path. getNode
is not shown here but it takes the ID as a parameter and returns an
object with the information returned from the database. You could also
store the relationship like this:

$pagedata = array(
1 => array('pagename',parid),
2 => array(...),
....
);

Hope I explained clearly enough and answered your question.

-Robert

crescent_au@yahoo.com wrote:
Quote:
Hi everybody,

I want to create dynamic breadcrumbs for a site I am developing. I just
want to get some views about the algorithm of breadcrumbs.

The way I look at it is the concept of parent/ child (main/ sub). I
have the "Home" page, which has links to sub-pages such as
"Introduction", "History", "Timetable", etc. Each page can have other
sub-pages, such as "Timetable" can have "Semester1", "Semester2", etc.
This is how I'd initially think. Am I on the right track? If yes, how
do I proceed? Do I need a database or is there another efficient way to
do it? If it is in fact the way I am thinking, then I think I need a
way to "register" or hold the data in some way and access it on each
page. I'm just lost here.

Please push me to the right direction.

Thanks
Ben
Back to top
Rik
*nix forums Guru Wannabe


Joined: 16 Nov 2005
Posts: 291

PostPosted: Fri Jul 21, 2006 12:35 pm    Post subject: Re: idea/ concept behind creating breadcrumbs Reply with quote

rlee0001 wrote:
Quote:
Well if you have a database then that would be a good place to start.
If you are not currently using a database you could store the
relationships in an include file and include_once it into each page.

For a database I would do something like:

"id","pagename","parent_id"
1,"Home",0
2,"Introduction",1
3,"History",1
4,"Timetable",1
5,"Semester1",4
6,"Semester2",4
...

Then use a recursive function to "walk" up and down the tree:

function printnode($node) {
if ($node->parent_id) {
printnode(getNode($node->parent_id));
}
echo $node->pagename;
return;
}

If you want breadcrumbs, with a hierarchical table, it might be worth it to
use the nested set model instead of the adjacency model:

http://dev.mysql.com/tech-resources/articles/hierarchical-data.html

Grtz,
--
Rik Wasmus
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
The time now is Sat Nov 22, 2008 9:00 pm | All times are GMT
navigation Forum index » Programming » PHP
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Creating relational view for an ODBC result set? antilog@gmail.com Server 0 Fri Jul 21, 2006 5:56 am
No new posts Exim4 not creating and/or receiving incoming mail... jtelep@localonline.net Exim 1 Fri Jul 21, 2006 1:59 am
No new posts Creating a relationship between 2 tables Andyza Oracle 2 Thu Jul 20, 2006 1:11 pm
No new posts creating another database on the same box ? newhorizon Server 3 Thu Jul 20, 2006 9:18 am
No new posts Error when creating Foreign Key Jesse MySQL 5 Wed Jul 19, 2006 5:25 pm

Credit Cards | Credit Counseling | Loans | Remortgages | Loans
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1702s ][ Queries: 16 (0.0847s) ][ GZIP on - Debug on ]