Hello Group,
I came up with a hopefully useful hack for the findAllThreaded
function.
I have a self-joining table called category with these fields: id,
parent_id, name, description
My users will be able to browse through the different categories, and
will see a tree structure of categories underneath the current
category.
findAllThreaded the way it is right now returns an array of the entire
tree structure starting from the top (root). For my app I need the tree
structure only starting from a specified category id.
Looking at the sub-function __doThread you can see that it is using a
$root variable. Unfortunately the initial findAllThreaded function does
not allow you to specify a root variable.
So here is my "hacked" findAllThreaded function:
function findAllThreaded($root = null, $conditions = null, $fields =
null, $sort = null) {
return $this->__doThread(Model::findAll($conditions, $fields,
$sort), $root);
}
When you call now findAllThreaded($id_of_current_category) it will only
return the tree structure below that category, not the whole tree
structure.
If you want the whole thing, just leave the first var empty.
I hope this helps a few people out there.
Thanks to Spark for his help with this.
Greg
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---