Skip to content

Instantly share code, notes, and snippets.

@dchatry
Last active January 25, 2017 14:20
Show Gist options
  • Save dchatry/24879b3eb613127971bdde2098ff9471 to your computer and use it in GitHub Desktop.
Save dchatry/24879b3eb613127971bdde2098ff9471 to your computer and use it in GitHub Desktop.
[Drupal] Print menu tree to be imported in Taxonomy Manager
<?php
$tree = menu_tree_all_data('main-menu');
function _explore($trees) {
foreach($trees as $label => $sub) {
if($sub['link']['hidden'] != 1) {
$label = preg_replace('/[0-9]+/', '', $label);
print str_repeat('-', ($sub['link']['depth'] - 1)) . trim($label) . "<br />";
if(isset($sub['below'])) {
_explore($sub['below']);
}
}
}
}
_explore($tree);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment