|
|
|
|
|
|
| Author |
Message |
crescent_au@yahoo.com *nix forums beginner
Joined: 21 Nov 2005
Posts: 6
|
Posted: Fri Jul 21, 2006 12:10 am Post subject:
idea/ concept behind creating breadcrumbs
|
|
|
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
|
Posted: Fri Jul 21, 2006 12:18 am Post subject:
Re: idea/ concept behind creating breadcrumbs
|
|
|
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
|
Posted: Fri Jul 21, 2006 2:18 am Post subject:
Re: idea/ concept behind creating breadcrumbs
|
|
|
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
|
Posted: Fri Jul 21, 2006 12:35 pm Post subject:
Re: idea/ concept behind creating breadcrumbs
|
|
|
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 |
|
 |
|
|
The time now is Sat Nov 22, 2008 9:00 pm | All times are GMT
|
|
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
|
|