|
Posted by Rik on 10/20/28 11:53
rlee0001 wrote:
> 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
Navigation:
[Reply to this message]
|