Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 761683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:52:04+00:00 2026-05-14T15:52:04+00:00

I really only need the mlid and title text for the first level below

  • 0

I really only need the mlid and title text for the first level below a certain menu item. Here’s what I’m doing at the moment. (It works, but I suspect there may be a more drupal-y way.):

/**
 * Get all the children menu items below 'Style Guide' and put them in this format:
 * $menu_items[mlid] = 'menu-title'
 * @return array
 */
function mymod_get_menu_items() {
    $tree = menu_tree_all_data('primary-links');
    $branches = $tree['49952 Parent Item 579']['below']; // had to dig for that ugly key
    $menu_items = array();
    foreach ($branches as $menu_item) {
        $menu_items[$menu_item['link']['mlid']] = $menu_item['link']['title'];
    }
    return $menu_items;
}

Is there?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:52:04+00:00Added an answer on May 14, 2026 at 3:52 pm

    afaik, there isn’t (i hope i am wrong).
    for the while, instead of digging for ugly keys, you can turn your function into a more abstract helper function by simply adding a foreach ($tree). then you can use your own logic to output what you want (mlid, in this case). here is my suggestion:

    
    /**
     * Get the children of a menu item in a given menu.
     *
     * @param string $title
     *   The title of the parent menu item.
     * @param string $menu
     *   The internal menu name.
     * 
     * @return array
     *   The children of the given parent. 
     */
    function MY_MODULE_submenu_tree_all_data($title, $menu = 'primary-links') {
      $tree = menu_tree_all_data($menu);
      foreach ($tree as $branch) {
        if ($branch['link']['title'] == $title) {
          return $branch['below'];
        }
      }
      return array();
    }
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started out with jQuery and really only need it for some very
For example: (1).SomeFunction().Equals(one) (2).SomeFunction().Equals(two) I really only need it for digits 1-9 in the
We've got a test site hosted only by IP address. We really need to
I'm building a simple blog-style application. I really only need admin and non-admin users,
I really only need my ScrollView wrapped around 1 of the 3 LinearLayout s
I am using jQuery UI to create 2 tabs. I really only need the
I'm really only familiar with the C calling convention at this time (as described
I am really only a hobbyist, who has aspirations far too grand, that said,
Firstly, when I say other browsers I really only mean Firefox because that's all
I'll admit I'm a novice programmer and really the only experience I have is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.