azhpo
azhpo

Reputation: 802

Joomla 2.5 get menu children

I have been searching for this and didn't find anything. I know how to get the parent menu name and the active page, but couldn't find how could I get the NOT active children.

This is what I have:

$menu = &JSite::getMenu();
$active = $menu->getActive();
$activeChild = $active->title;
$parentId = $active->tree[0];
$parentName = $menu->getItem($parentId)->title;
$menu = &JSite::getMenu();
echo "<hr>";
echo $parentName . " > " . $activeChild;

Example menu: - Menu -- Sub1 -- Sub2 -- Sub3

If we are in Sub2 page the output is: Menu > Sub2

But how can I output the other children too? In their native order?

Upvotes: 0

Views: 1211

Answers (1)

Irfan
Irfan

Reputation: 7059

I am getting that you want to get all children of active parent.If yes,You can try below code -

$menu = &JSite::getMenu();
$active = $menu->getActive();
$activeChild = $active->title;
$parentId = $active->tree[0];
$parentName = $menu->getItem($parentId)->title;
$childs = $menu->getItems( 'parent_id', $parentId);
echo '<pre>';print_r($childs);echo '</pre>';

Upvotes: 2

Related Questions