0

my current menu links are generated but those are not the alias urls as follows:

theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('class' => array('nav nav-pills'))));

I would like that the menu generated is with alias urls instead the 'content/name-of-node'. How do you generated menu with alias path links? Is there function i can get only array of links for the main manu, so i can parse out the html myself? Thank You for help

p.s. This is Drupal 7.

1

1 Answer 1

0

Thank You Chris...the menu_load_links() was exactly what i was looking for. Here is my custom main menu array that i later parse in html teplates as needed:

$mainMenuArray = menu_load_links('main-menu');
$finalMainMenu = array();
foreach($mainMenuArray as $key=>$menuItem){
    $finalMainMenu[$key]['active'] = false;
    $linkPath = $menuItem['link_path'];
    $linkPathAlias = drupal_get_path_alias($linkPath);
    $currentId = $vars['node']->nid;
    if(drupal_get_path_alias("node/$currentId") == $linkPathAlias)$finalMainMenu[$key]['active'] = true;
    $finalMainMenu[$key]['url'] = $linkPathAlias;
    $finalMainMenu[$key]['title'] = $menuItem['link_title'];
}
$vars['mainMenu'] = $finalMainMenu;

I have this in template.php hook 'theme_preprocess_page' where the $vars['node'] is used to determine what is the current node loaded. I hope it useful for someone. Thank you Chris for answering my question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.