OK, this is the get page code, and tree at the bottom of the
www.hklc.com/midgard_manual
It would need some work to merge with the current news code -
eg. change the way that articles are got based on their name - this would need
more work to map name->article
anyway - It will create a tree navigation - and should be reasonably commented
so you can understand what to do with it....
It may not be the best solution to the problem :) - eg. most flexible....
regards
alan
///----------------------------------------------------------------
/// PAGE CODE-INIT
///-----------------------------------------------------------------
// code to get the current article based on url
// the purpose of this is to get
// $article = (really the artilce or topic object);
// $id = the id of the object
// $type = the type of the object
// name of top level topic!
$baseobj = mgd_get_topic_by_name(0, "Midgard Admin Interface Manual");
// if nothing found use the top level!
$article = $baseobj;
list($type,$id) = explode("_",$argv[0]);
//sneaky trick to get object by type
$function = "mgd_get_".$type;
if (function_exists($function)) {
if ( $object = $function($id)) {
// check that it is in the tree!
// and set $article to the value if correct.
switch ($type) {
case "article":
if (mgd_is_article_in_topic_tree($baseobj->id, $object->id))
$article = $object;
break;
case "topic":
if (mgd_is_in_topic_tree($baseobj->id, $object->id))
$article = $object;
break;
}
}
}
///-------------------------------------------------------------------------
/// END CODE INIT CODE.
///-------------------------------------------------------------------------
///-------------------------------------------------------------------------
/// This is our <[tree_snippet]>
///-------------------------------------------------------------------------
<?
/// simple function that prints out <LI><A href="link">name</A>
function downtree($id,$level) {
// output this one..
global $article,$type;
// GET this topic!
// if not this one!
if (($article->id != $id) && ($type == "topic")) {
/// ITS A TOPIC AND NEEDS DISPLAYING - used when doing partial trees!
/// have a look at www.hklc.com/midgard_manual to see how the tree changes
$topic = mgd_get_topic($id);
/// STRIPS OFF "1. " from beginning of name - this was used before we
/// added score manipulation into nadmin. - althouh it is i tidy way
/// to display topics & articles
$topic->name = ereg_replace("^[0-9]+\.[ ]*","",$topic->name );
?><LI><a href="topic_&(id);" class="bold">&(topic.name);</A></LI><?
}
?><UL><?
// OK, Ive shown the topic, now list the articles below!
if ($list = mgd_list_topic_articles($id,"alpha")) {
while ($list->fetch()) {
// if there is a title use that rather than the name!
if ($list->title) $list->name = $list->title;
// get rid of the "1. " as before.
$list->name = ereg_replace("^[0-9]+\.[ ]*","",$list->name );
// IF IT IS THE SELECTED ONE (eg this $article->id)
// show it as italic
if (($type == "article") && ($article->id == $list->id)) {
?><LI><i>&(list.name);</i></LI><?
}else {
// otherwise, a normal link
?><LI><a href="article_&(list.id);">&(list.name);</A></LI><?
}
}
}
// now list the topics // and recursively call myself!
if ($downlist = mgd_list_topics($id))
while ($downlist->fetch())
downtree($downlist->id,$level+1);
?></UL><?
}
///---------------------------------------------------------
/// THIS IS WHERE THE PROGRAM REALLY BEGINS!!
// has $type been set, if not set it to topic
if (!ereg("(article|topic)",$type)) $type = "topic";
// NOW THIS LISTS EVERY THING BELOW THIS TOPIC
// you could just use
// downtree($baseobj->id,0) to always show the whole tree
if ($type != "article") {
downtree( $article->id, 0);
} else {
downtree( $article->topic, 0);
}
?>
/// <[tree_snippet]>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]