PHP Classes

Display just a part of the nodes

Recommend this page to a friend!

      Nested Nodes Class  >  All threads  >  Display just a part of the nodes  >  (Un) Subscribe thread alerts  
Subject:Display just a part of the nodes
Summary:I would like to display just a part of the nodes
Messages:4
Author:Dennis
Date:2007-02-18 19:48:10
Update:2007-02-20 00:54:33
 

  1. Display just a part of the nodes   Reply   Report abuse  
Picture of Dennis Dennis - 2007-02-18 19:48:10
First of all: A great class, it works almost perfectly. Except a minor change in the test page ( removed a variable c_icon from a query ) and of course the problem mentioned in the earlier tried by another tester.

I would like to display just a part of the nodes and I am curious how I can achieve this. For Example:

I have a navigation structure with seperate horizontal and vertical navigation div's.

---

Horizontal nav ( All root elements )

Home [ id='1', position='1>', ord='0' ]
About [ id='2', position='2>', ord='0' ]
News [ id='3', position='3>', ord='0' ]

Vertical nav ( All child elements, based somewhere else on the same page as the root nav )

About01 [ id='4', position='2>4>', ord='1' ] ( first level node )
About02 [ id='5', position='2>5>', ord='2' ] ( first level node )
About03 [ id='6', position='2>6>', ord='3' ] ( first level node )
About04 [ id='7', position='2>7>', ord='4' ] ( first level node )

---

Now I would like to now how I can just display the horizontal nav, in this case al root elements. And how I can just display the vertical nav, in this case just 1 level of nodes from the root element ABOUT.

I tried several things, but I can find a good solution. My guess is that it should be possible to write a function that excepts the ID of a specific page ( For example: id='7' ) and then, based on that Id generates a one level navigation from all the nodes within the same level.

I hope someone knows an answer to this problem!

With kind regards




  2. Re: Display just a part of the nodes   Reply   Report abuse  
Picture of S.Shaban S.Shaban - 2007-02-18 22:24:10 - In reply to message 1 from Dennis
hello,

Thanks for your positive comments.

for your problem i see that you want to display a vertical list of the node 2 children.

this is done by the following function:

$vertical_nodes = $nodes->browse_by_id(2);

now you have the children of the node 2 (About) inside the variable $vertical_nodes as array.


to get a list of the roots only .. you may use

$horz_nodes = $nodes->build_list(0 , TRUE);

now you have the roots categories only because the second paramater (clickable) is set to true.


use foreach command or something to print it out.

let me know if that what you mean ?


  3. Re: Display just a part of the nodes   Reply   Report abuse  
Picture of Dennis Dennis - 2007-02-19 18:06:41 - In reply to message 2 from S.Shaban
Hello,

That's it, of course. Thank you for your quick reply. This works perfectly!

And about the earlier thread "Subnodes not moving", is there a solution for that problem? Maybe someone can post that solution in the thread then.


[Just an example how I implemented the function for other readers]

<?php

$vertical_nodes = $nodes->browse_by_id(2);
/*
// Display the array for testing purpose
echo "<pre>";
print_r($vertical_nodes);
*/

// Display a navigation structure
if (is_array($vertical_nodes)) {
$testnav = "<ul>\n";

foreach ($vertical_nodes as $tn) {
$testnav .= "<li><a href=\"test.php?id=". $tn['0'] ."\">". $tn['3'] ."</a></li>\n";
}
$testnav .= "</ul>\n";
} else {

$testnav .= '<p>Geen array</p>';
}
echo $testnav;

?>


With kind regards,


Dennis

  4. Re: Display just a part of the nodes   Reply   Report abuse  
Picture of S.Shaban S.Shaban - 2007-02-20 00:54:33 - In reply to message 3 from Dennis
Hello,

I'm working on the sub-nodes not moving problem and it should be fixed withing a few hours.

stay tuned,


Thank you.