Reputation: 83
I have a problem:
function drupal_menu_link($variables) {
$element = $variables['element'];
$sub_menu = $element['#below'] ? drupal_render($element['#below']) : '';
return '<a href="/drupal/'.$element['#href'].'" title = "'.$element['#title'].'" ><li' . drupal_attributes($element['#attributes']) . '>' . $element['#title'] .'</li></a>';
}
How can I base on aliases, not the hrefs? When I hover on an element I see node/number instead of alias. I made a redirection, but it happens after click. Can somebody help me? I was looking for that in other themes but I am bad at it and I just don't understand how it works.
Upvotes: 0
Views: 260
Reputation: 1299
To transform an node/{number} - url to an existing url_alias, you could use the url method.
return '<a href="/drupal/'.url($element['#href']).'" title = "'.$element['#title'].'" ><li' . drupal_attributes($element['#attributes']) . '>' . $element['#title'] .'</li></a>';
A better way would be, to use the l method to generate the complete link:
return l($element['#title'], $element['#href'], array('attributes'=>$element['#attributes']));
Upvotes: 2
Reputation: 27023
To return the path alias, use drupal_get_path_alias
drupal_get_path_alias("node/" . $nid);
Upvotes: 0