on 3/1/01 8:36 PM, Alan Knowles at [EMAIL PROTECTED] wrote:
> 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....
Ok, I've gone about as far as I can to use this code for standard
navigation. It's still not as standard as it should be. So I'm asking for
some help from you guys that know how to code. I'm including below the two
page elements which currently work on:
http://www.accollarts.net/example/example4
The current set up displays only the 'named' topic tree, including sub
topics and all articles. When selecting any article in sub topics, the
navigation changes to only display the sub topic and articles. This is not
what I consider standard navigation.
What needs to occur is the following:
1. main page only displays ALL topics only
a. clicking on topic, displays topic and articles, or
1. if sub topics exist, then only sub topics
a. clicking sub topics displays article links
1. clicking article displays article
2. a link back to the previous sub topic, topic, main page via a "back" link
Note that the description for topics/sub topics, and/or abstract and content
display in the main section of the table for the page. This is way cool!
If anyone could help me with this code, the newbie user community would
greatly appreciate it! As I've said before, once there is a set of standard
navigation code completed, I will be happy to do whatever it takes to give
the code to midgard and hklc so it can be included in their respective
manuals.
If you do respond with code suggestions, PLEASE comment it so the not so
knowledgeable users can make heads or tails out of it ;-)
Thanks in advance!
enrique
// ------------------ <[tree-snippet]> page element START ----------------
<?
/// simple function that prints out <A href="link">name</A><BR>
function downtree($id,$level) {
// output this one..
global $article,$type;
/// 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);
/// if it's a topic then the description will be listed and italisize the
topic
if (($type == "topic") && ($article->id == $id)) {
?><HR><FONT SIZE="-1"><B><i>&(article.name);</i></B></FONT><BR><?
}else {
/// 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 );
?><HR><FONT SIZE="-1"><B><a href="topic_&(id);"
class="bold">&(topic.name);</A></B></FONT><BR><?
}
// 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)) {
?><FONT SIZE="-2"><B>° <i>&(list.name);</i></B></FONT><BR><?
}else {
// otherwise, a normal link
?><FONT SIZE="-2"><B>° <a
href="article_&(list.id);">&(list.name);</A></B></FONT><BR><?
}
}
}
// now list the topics // and recursively call myself!
if ($downlist = mgd_list_topics($id))
while ($downlist->fetch())
downtree($downlist->id,$level+1);
}
///---------------------------------------------------------
/// 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( $article->id, 0) to only show the topic tree
if ($type != "article") {
downtree($baseobj->id,0);
} else {
downtree( $article->topic, 0);
}
?
// ------------------ <[tree-snippet]> page element END!-------------------
// ------------------ <[code-init]> page element START -------------------
<?
///----------------------------------------------------------------
/// 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, "Topic 1");
// if nothing found use the top level!
if (!$baseobj) { print "Opps no top level object found"; exit; }
$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;
}
}
}
?>
// ------------------ <[code-init]> page element END! -------------------
// ------------------------ example4 page code ------------------------
<HTML>
<HEAD>
<TITLE><[title]></TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<P ALIGN=center><CENTER><TABLE BORDER=1 CELLPADDING=4 WIDTH=600>
<TR>
<TD COLSPAN=2>
<H2 ALIGN=center>HEADER - <[title]></H2>
</TD>
</TR>
<TR>
<TD VALIGN=top NOWRAP WIDTH="10%">
<CENTER><B>TOPIC HEADER</B></CENTER>
<FONT SIZE="5"><[tree_snippet]></FONT>
</TD>
<TD VALIGN=top>
<P><FONT
SIZE="+1"><i>&(article.abstract);</i></FONT><P>&(article.description);
&(article.content);
</TD>
</TR>
<TR>
<TD COLSPAN=2>
<H6 ALIGN=center>FOOTER</H6>
</TD>
</TR>
</TABLE></CENTER>
</BODY>
</HTML>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]