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

  • Home
  • SEARCH
  • 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 6913453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:13:16+00:00 2026-05-27T09:13:16+00:00

Reading the documentation for menu_tree_page_data() , it seems to me that I should be

  • 0

Reading the documentation for menu_tree_page_data(), it seems to me that I should be able to retrieve the entire contents of my main menu by calling the function in the following way: menu_tree_page_data('main-menu'). Since param 2, $max_depth, defaults to NULL, this should recursively go through all levels. Since param 3, $only_active_trail, defaults to FALSE, this should retrieve all links, not just those on the active trail.

However, when calling this function, I end up with the following type of tree data.

All links on the first level of depth.
All links on the second level of depth.
Only active links on the third level of depth.

What’s going on here? I’ve also tried explicitly setting params as menu_tree_page_data('main-menu', 10, FALSE) just to make sure that I was not misinterpreting the default behavior. I’ve had to write my own function to give me the entire menu, but it doesn’t have active-trail data. Now, I’m finding myself in a situation where I’m blending the two functions to create a full menu tree WITH active-trail information, and it is extremely messy. It’d be great if one solution just worked.

Alternatively, is there a simple way of determining active trail for a given menu item? If so, I’ll just add that to my already-working tree-crawler function and call it a day.

  • 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-27T09:13:16+00:00Added an answer on May 27, 2026 at 9:13 am

    I think it’s a problem with the static caching in menu_tree_page_data(). The cache ID is built up using (among other things) the $max_depth passed into the function or MENU_MAX_DEPTH, whichever is smaller.

    Since MENU_MAX_DEPTH is equal to 9, when you pass 10 into the function this is automatically reset to 9, and the cache ID is built from that. If another function has already called menu_tree_page_data() with MENU_MAX_DEPTH as the $max_depth argument (which does happen earlier on in a Drupal page), and with $only_active_trail set to TRUE then the statically cached data will be returned with only active trail items.

    I think the following will work:

    drupal_static_reset('menu_tree_page_data');
    $tree = menu_tree_page_data('main-menu');
    

    If it doesn’t, you might also need to clear the cache for another function that’s involved (_menu_build_tree()) so try this:

    drupal_static_reset('_menu_build_tree');
    drupal_static_reset('menu_tree_page_data');
    $tree = menu_tree_page_data('main-menu');
    

    Hope that makes sense it’s quite tricky to explain 🙂

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

Sidebar

Related Questions

Reading the documentation it seems this might not be possible, but it seems that
Reading Kohana's documentation, I found out that the main difference in 3.0 version is
reading the documentation for java org.w3c.dom.ls it seems as a Element only can be
Reading through documentation, I found following: 1.9.1 1.8.4 1.8.2 A version of 1.8.2 select
I know from reading Microsoft documentation that the "primary" use of the IDisposable interface
After reading the documentation for MySQL Workbench I got the impression that it's possible
I'm new to HTML. When I started reading documentation about lists, I've noticed that
I have been reading documentation about the new features that IIS 7.5 offers regarding
While reading the documentation for boost::test, I came across the term free function. What
From reading the documentation, it seems like you must send an array of bytes

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.