VOilà, mais je pense pas que c'est le problème, quoi je pense...
array(
(int) 0 => array(
'Category' => array(
'id' => '25',
'name' => 'Root',
'lft' => '1',
'rght' => '16',
'parent_id' => '0',
'slug' => 'categories',
'post_count' => '0',
'link' => array(
'controller' => 'posts',
'action' => 'category',
'slug' => 'categories'
)
),
'children' => array(
(int) 0 => array(
'Category' => array(
'id' => '26',
'name' => 'Publications',
'lft' => '2',
'rght' => '9',
'parent_id' => '25',
'slug' => 'publications',
'post_count' => '1',
'link' => array(
'controller' => 'posts',
'action' => 'category',
'slug' => 'publications'
)
),
'children' => array(
(int) 0 => array(
'Category' => array(
'id' => '29',
'name' => 'Article',
'lft' => '5',
'rght' => '6',
'parent_id' => '26',
'slug' => 'article',
'post_count' => '0',
'link' => array(
'controller' => 'posts',
'action' => 'category',
'slug' => 'article'
)
),
'children' => array()
),
(int) 1 => array(
'Category' => array(
'id' => '28',
'name' => 'Books',
'lft' => '3',
'rght' => '4',
'parent_id' => '26',
'slug' => 'book',
'post_count' => '1',
'link' => array(
'controller' => 'posts',
'action' => 'category',
'slug' => 'book'
)
),
'children' => array()
),
(int) 2 => array(
'Category' => array(
'id' => '30',
'name' => 'Poster',
'lft' => '7',
'rght' => '8',
'parent_id' => '26',
'slug' => 'posters',
'post_count' => '0',
'link' => array(
'controller' => 'posts',
'action' => 'category',
'slug' => 'posters'
)
),
'children' => array()
)
)
),
(int) 1 => array(
'Category' => array(
'id' => '27',
'name' => 'Researches',
'lft' => '10',
'rght' => '15',
'parent_id' => '25',
'slug' => 'researches',
'post_count' => '0',
'link' => array(
'controller' => 'posts',
'action' => 'category',
'slug' => 'researches'
)
),
'children' => array(
(int) 0 => array(
'Category' => array(
'id' => '32',
'name' => 'Actived',
'lft' => '13',
'rght' => '14',
'parent_id' => '27',
'slug' => 'actived',
'post_count' => '0',
'link' => array(
'controller' => 'posts',
'action' => 'category',
'slug' => 'actived'
)
),
'children' => array()
),
(int) 1 => array(
'Category' => array(
'id' => '31',
'name' => 'Unactived',
'lft' => '11',
'rght' => '12',
'parent_id' => '27',
'slug' => 'unactived',
'post_count' => '0',
'link' => array(
'controller' => 'posts',
'action' => 'category',
'slug' => 'unactived'
)
),
'children' => array()
)
)
)
)
)
)
Si je modifie ma fonction ainsi, ca marche bien:
function subMenu($tableau){
?><ul><?php
foreach($tableau as $k => $v){
?><li><?php
echo $v'Category']'post_count'];
echo $v'Category']'name'];
if(is_array($v'children']) && !empty($v'children'])){
subMenu($v'children']);
}
?></li><?php
}
?></ul><?php
}
ca m'affiche ca :
Root
- 1Publications
-- 0Article
-- 1Books
-- 0Poster
- 0Researches
-- 0Actived
-- 0Unactived