default menu-trim block

promes - March 1, 2009 - 10:24
Project:Menu Trim
Version:5.x-1.0
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:postponed (maintainer needs more info)
Description

In some of my projects I need one of the trimmed menu's te be open if no other menu is shown. For instance when a system page is shown (like search/node or contact).
I created a code-snippet to make this happen in the original (not-trimmed) block: this block opens when no trimmed block is shown.
Maybe this can be added in to make other happy users even more happy.

<?php
 
// get all trimmed menu blocks
 
$blocks = menu_trim_block('list');
  if (
is_array($blocks))  {
    foreach(
$blocks as $mid => $info) {
     
$data = menu_trim_block('view', $mid);
     
// if block is shown don't show the default block
     
if ($data) {
        return
FALSE;
      }
    }
  }
 
// no trimmed menu present, so show this block
 
return TRUE;
?>

Now this code is added in the settings part of the block (in administer >> blocks) on the bottom in visibility. Attention: use "use PHP code".
Thanks for this smart module.

#1

NancyDru - March 1, 2009 - 19:24
Status:active» postponed (maintainer needs more info)

I'm kind of confused as to how to use this; I assume it belongs in the TI Blocks contrib. I'm also wondering if it might fit better with #366788: Modify a block programatically before display.

#2

promes - March 6, 2009 - 10:16

Hello Nancy,

I use it with menu-trim, not taxonomy image, since for me it is logically connected with trimmed menus. So please put this comment back to module menu-trim.
I use trimmed menus in several projects together with primary menu's. When somebody selects, for instance, the contact link in the primary menu, none of the trimmed menu's will be shown. In that case I mostly like to have a default menu that otherwise is trimmed.
For me it could be an extra option in the menu-trim settings. Now we have "never trim", "allow trim" and "allow trim, hide when inactive". If we have an extra option "allow trim, hide when inactive, set as default" (only allowed for one menu ??), my code can show this menu whenever no other side menu is selected. That exactly the way I use it, but with my code I have to put it in the original menu-block to select this block only if no trimmed menu will be shown.
So, I my view, taxonomy image (a module I also use), doesn't have to do nothing with this code. And I was looking at #366788, but couldn't link my intention to that project either.

An example you can see on www.dosgg.nl/search. The CompUsers menu will be shown thru my code. If you press Home in the primary links the same menu will be shown by menu-trim. If you go to another primary link (except eshop --> external site) this menu wil not be shown.

#3

promes - March 7, 2009 - 10:23
Project:Taxonomy Image» Menu Trim
Version:5.x-1.5» 5.x-1.0

Changed to menu trim.

 
 

Drupal is a registered trademark of Dries Buytaert.