Drupal
Comment faire pour supprimer la hiérarchie dans le menu sans la supprimer dans l’affichage du chemin.
Il faut simplement ajouter ces quelques lignes : $output = str_replace(”collapsed”, “leaf”, $output); $output = str_replace(”expanded”, “leaf”, $output); $chaine_deb = “<ul”; $chaine_fin = “</ul>”; $deb = strpos($output, $chaine_deb); if($deb){
$fin = strpos($output, $chaine_fin); if($fin){ $output = substr($output, 0, $deb).substr($output, $fin + strlen($chaine_fin)); }
}
dans la fonction menu_tree.
2 Comments so far
Leave a reply
Merci pour l’info,
j’ai découvert également cette fonction, qui est très souple, (permet de définir des paramètres d’affichage différents pour plusieurs menus/blocs, ainsi que la gestion du breadcrumb.)
menu_set_location()
api.drupal.org/api/4.7/fu…
————————————————————————
function menu_set_location($location) {
global $_menu;
$temp_id = min(array_keys($_menu[’items’])) - 1;
$prev_id = 0;
// Don’t allow this function to change the actual current path, just the
// position in the menu tree.
$location[count($location) - 1][’path’] = $_GET[’q'];
foreach (array_reverse($location) as $item) {
if (isset($_menu[’path index’][$item[’path’]])) {
$mid = $_menu[’path index’][$item[’path’]];
if (isset($_menu[’visible’][$mid])) {
// Splice in the breadcrumb at this location.
if ($prev_id) {
$_menu[’items’][$prev_id][’pid’] = $mid;
}
$prev_id = 0;
break;
}
else {
// A hidden item; show it, but only temporarily.
$_menu[’items’][$mid][’type’] |= MENU_VISIBLE_IN_BREADCRUMB;
if ($prev_id) {
$_menu[’items’][$prev_id][’pid’] = $mid;
}
$prev_id = $mid;
}
}
else {
$item[’type’] |= MENU_VISIBLE_IN_BREADCRUMB;
if ($prev_id) {
$_menu[’items’][$prev_id][’pid’] = $temp_id;
}
$_menu[’items’][$temp_id] = $item;
$_menu[’path index’][$item[’path’]] = $temp_id;
$prev_id = $temp_id;
$temp_id–;
}
}
if ($prev_id) {
// Didn’t find a home, so attach this to the main navigation menu.
$_menu[’items’][$prev_id][’pid’] = 1;
}
$final_item = array_pop($location);
menu_set_active_item($final_item[’path’]);
}
Ou encore…
——————————————————————————–
<?php
function toto_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
if ($node->type == ’story’ && $op == ‘view’ && $page) {
global $_menu;
$path = ‘path/to/attach’; // (1)
$mid = $_menu[’items’][menu_get_active_item()][’pid’]; // (2)
$pid = $_menu[’path index’][$path]; // (3)
$_menu[’items’][$mid][’pid’] = $pid; // (4)
}
}
?>
——————————————————————————–
En gros :
* (1) je définis le chemin auquel je veux rattacher mon node
* (2) je chope l’id de l’actuel parent de mon node dans la structure du menu
* (3) je chope l’id du futur parent de mon node dans la structure du menu
* (4) je remplace l’actuel parent par le nouveau