Hi!
On Fri, 2004-03-12 at 18:32, Sonic wrote:
> Ok, so far so good. It now have the correct topic id, but for some
> reason, list_leaves seems to return the wrong article ids.
As I said before, "this mapping is not true for leaves however". I.e.,
list_leaves does *not* return Article IDs. Why not? The answer is
simple: NAP is component independent. Imagine a component that stores
data in the file system instead of in the Midgard database. This
component will provide leaves as well, but these leaves won't have
Article IDs. So the leaf IDs have to be different from Article IDs.
> $nav = new midcom_helper_nav();
> $loc = $nav->get_current_node();
> $children = $nav->list_leaves($loc);
> foreach ($children as $child){
> $article = mgd_get_article($child);
> ?><a href="&(article.url);">&(article.title);</a><br><?
> }
And this is what NAP::get_leaf is for, try these lines:
- - - - 8< - - - -
$nap = new midcom_helper_nav(); // Get the NAP class
$midgard = $GLOBALS["midcom"]->get_midgard();
$urlprefix = $midgard->self; // Page URL
$current_node = $nap->get_current_node(); // Where are we?
$n = $nap->get_node($current_node); // Get node information
if ($leaves = $nap->list_leaves($node)) { // Check if there are leaves
echo "<ul>";
foreach ($leaves as $leaf) {
// $leaf is a leaf ID that is unique in this node (Topic)
$l = $nap->get_leaf($leaf); // Get leaf information
$title = $l[MIDCOM_NAV_NAME];
$url = $urlprefix . $n[MIDCOM_NAV_URL] . $l[MIDCOM_NAV_URL];
echo "<li><a href=\"$url\">$title</a></li>";
}
echo "</ul>";
}
- - - - 8< - - - -
As you see, I use the NAP data for the Topic (node!) and the NAP data
for the Child (leaf!) to construct an absolute URL.
You can get an overview on what data is provided by get_leaf and
get_node, you can have a look at the MidCOM Specification, which is
currently here: (we still need to move it to Tigris and update it):
http://www.nehmer.net/~torben/midcom-specs/node16.html#SECTION00524000000000000000
Nico.
--
Nico Kaiser ::
[EMAIL PROTECTED] :: http://siriux.net/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]