On Dec 11, 3:10 pm, ahmed fakher <spcial...@gmail.com> wrote:
> i user tree behavior,,but i build it like this table >> all parent
> must be null field not the top parent only..i know that is wrong

why is that wrong?

> but i
> need it to build menus...

You do not need the tree behavior for something related to menus -
there simply isn't enough data to warrant the overhead/complexity IMO.

> i use helper for that..but the problem i need
> if the user click on Entertainment (parent) see all articles in
> music(child) and movies(child),,so i check if Entertainment is null
> find his children
>
> |-------------|----------------- --------------|----------|-
> |    Id      |  Parent_id   |    lft      |  rght   |  name
> | -------------------------------|------------|----------
> |-------
> |   89      |     NULL      |   25     |   30     |  Entertainment
> |            |                   |            |           |
> |    90    |       89         |    26     |    27   |   Music
> |            |                   |            |           |
> |   91     |       89         |   28     |      29  |  Movies

Ic so the menu is a representation of a 'justified' use of the tree
behavior.

why does it matter if the parent_id is null - I would not bother even
checking if parent id is null. What I think you're really saying is
"when a category has sub categories"

Do something like this:

$categories = array($requestedId);
$children = $this->Category->findChildren($requestedId, false,
array('id'))
foreach($children as $child) {
 $categories[] = $child['Category']['id'];
}

$stuff = $this->Article->find('all', array(
  'conditions' => array('category_id' => $categories
));

AD

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to