I want to add a tree of links to a custom menu that already exists (created in admin/build/menu). I want to do this programatically based on an array I have. I don't maintain the menu but if it's there I need certain links to exist in it.

Given:

  • Menu A
    • Item A
    • Item B

I want:

  • Menu A
    • Item A
    • Item B
    • Item C
      • Item C.1
      • Item C.2
        • Item C.2.a
        • Item C.2.b
        • Item C.2.c
        • Item C.2.d
      • Item C.3

What's the best way to go about this? I've tried hook_menu and hook_menu_alter and can get my items to show in the menu but not according to their tree design. My $items array looks like this:

<?php

$items['C'] = array(...);
$items['C/1'] = array(...);
$items['C/2'] = array(...);
$items['C/2/a'] = array(...);
$items['C/2/b'] = array(...);
$items['C/2/c'] = array(...);
$items['C/2/d'] = array(...);
$items['C/3'] = array(...);

?>

All items are showing up on the same level though. What should I be specifying in array(...) that actually makes the tree? I was under the impression that the menu module based the tree structure on the keys of the $items array.

Thanks!

Comments

jody lynn’s picture

Status: Active » Closed (won't fix)

Closing this as an old support request