Jochem Maas wrote:
Chris wrote:
In further looking at the SPL classes, I'm thinking I want to use the
RecursiveFilterIterator class to filter my nodes.
But I ran into another problem: the class RecursiveFilterIterator
does not exist.
Am I missing something here?
your out on the bleeding edge so to speak - not many people have
played with
this stuff yet - alot will depend on the php build your using - best
bet is to try the
latest RC of 5.1 and see what that has in it .... I have a felling you
will
have to make a bit of use of the following funcs (and maybe even the
reflection API)
to figure out _exactly_ what is available in your build:
http://php.net/manual/en/function.get-declared-classes.php
http://php.net/manual/en/function.get-declared-interfaces.php
http://php.net/manual/en/function.get-class-methods.php
Thanks for the response. I'm really in love with most of the SPL stuff,
it's most unfortunate that some parts aren't ready yet. Upgrading would
be OK for my test server, but I was hoping to put this code on a PHP
5.0.3 server (upgrading there is an option, but a very undesirable one).
I'll look into precisely what is working on my 5.0.3 development server
at the moment. Any ideas if this functionality is likely to change?
Right now I'm specifically looking the Iterator and RecursiveIterator stuff.
I'll explain my precise situation in more detail in the hopes that
someone can make some suggestions or point out another way I might be
able to do this without filtering the RecursiveIterator.
I'm essentially storing the navigation of a Website in an object tree.
The root node (Home) has children, each of those has children, etc. My
tree definition file (an include that uses method calls to the CPage
object) creates the tree, and assigns different target areas for the
navigation to appear in.
So one CPage_Node might reside in the Top target, but send it's children
to the Left target. and One of those children might Send *it's* children
to the Tab target, while the rest jsut send theirs to the Left target.
So, for each target that is a Tree (displays a tree structure) I
Recursively Iterate the Full page tree, starting at the Root Node point,
but I have to stop displaying children that are being shown in another
target.
I can get it to work with the follwing code (using the
RecursiveIterator, but not the RecursiveFilterIterator)
$iTarget = $oPage->GetMenu(CPAGE_TARGET_LEFT)->GetTarget();
foreach($oPage->GetMenu(CPAGE_TARGET_LEFT)->GetRecursiveNodes() as $oNode)
{
if($oNode->GetTarget() != $iTarget) continue;
// Display the node here
echo str_repeat(' ',$oNode->GetLevel()),$oNode->GetName(),"\n";
}
Thanks,
Chris
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php