Skip to content

Instantly share code, notes, and snippets.

@kyleskrinak
Last active August 29, 2015 14:22
Show Gist options
  • Save kyleskrinak/dda3b969d2fc302643a9 to your computer and use it in GitHub Desktop.
Save kyleskrinak/dda3b969d2fc302643a9 to your computer and use it in GitHub Desktop.
It's crude and rude, but all I need for now. Give me all links off the main menu, so that I can use the resulting link list for creating site crawlers for QA
#!/usr/bin/env drush
// let user pass menu machine name
$arg = drush_shift();
print ( $arg );
// assign a default menu name
if ( empty($arg) ) {
$arg = "main-menu";
}
// Grab the links for main menu, our standard nav element
$tree = menu_load_links($arg);
foreach($tree as $key=>$menuItem) {
// We only care about the menu link
// Alias it while you're at it
$aPath = drupal_get_path_alias($menuItem['link_path']);
// It's possible to have external URLs in a menu tree
// we don't care about these
$hasHttp = stripos( $aPath, "http" );
if ( $hasHttp !== 0 ) {
// "<front>" won't work
if ( $aPath === "<front>" ) {
$aPath = "";
}
print( "/" . $aPath . "\xA" );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment