You are here: Re: idea/ concept behind creating breadcrumbs « PHP Programming Language « IT news, forums, messages
Re: idea/ concept behind creating breadcrumbs

Posted by rlee0001 on 12/04/16 11:53

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:
> 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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация