Quantcast

Lock icons in MM navigation menu?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Lock icons in MM navigation menu?

Hilary Caws-Elwitt

Hi all,

 

Dan’s probably the best person to answer this, but maybe others are doing it differently and/or would like to implement it too? At the Amherst College site, there’s a nifty feature of the MM tree navigation menu, where the lock icon indicates login required, unlock means restricted but viewable because you’re logged in, etc. (See https://www.amherst.edu/offices/human_resources for an example). We would love to investigate adding something like this, but I don’t see a hook to give access to the rendering (hook_mm_browser_links_alter exists for the tree browser but I can’t find an equivalent). And theme_menu_tree / theme_menu_item_link don’t seem to touch it (because it’s not a Drupal menu exactly, right?) Any suggestions?

--

Hilary Caws-Elwitt

IT Analyst - Five Colleges, Inc. - http://www.fivecolleges.edu

97 Spring St, Amherst MA 01002

[hidden email] - 413-542-4022

 

---

You are currently subscribed to monster_menus as: [hidden email].

To unsubscribe click here: http://lists.middlebury.edu/u?id=685503.6b071f880fe6a965a128164e6d09ea81&n=T&l=monster_menus&o=714637

(It may be necessary to cut and paste the above URL if the line is broken)

or send a blank email to [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Lock icons in MM navigation menu?

Jay Dansand

Dan, correct me if I’m wrong, but those are simply added via the classes “not-world” (not everyone-readable) and “denied,” which you should have in your links already.  I think you could just do the same in your own CSS.

 


-- 
Jay Dansand '08
Senior Web Application Developer
Technology Services, Seeley G. Mudd Library
Lawrence University
Appleton, WI
920-832-6585
[hidden email]

From: Hilary Caws-Elwitt [mailto:[hidden email]]
Sent: Friday, April 17, 2015 2:52 PM
To: Monster Menus Development
Subject: Lock icons in MM navigation menu?

 

Hi all,

 

Dan’s probably the best person to answer this, but maybe others are doing it differently and/or would like to implement it too? At the Amherst College site, there’s a nifty feature of the MM tree navigation menu, where the lock icon indicates login required, unlock means restricted but viewable because you’re logged in, etc. (See https://www.amherst.edu/offices/human_resources for an example). We would love to investigate adding something like this, but I don’t see a hook to give access to the rendering (hook_mm_browser_links_alter exists for the tree browser but I can’t find an equivalent). And theme_menu_tree / theme_menu_item_link don’t seem to touch it (because it’s not a Drupal menu exactly, right?) Any suggestions?

--

Hilary Caws-Elwitt

IT Analyst - Five Colleges, Inc. - http://www.fivecolleges.edu

97 Spring St, Amherst MA 01002

[hidden email] - 413-542-4022

 

---

You are currently subscribed to monster_menus as: [hidden email].

To unsubscribe click here: http://lists.middlebury.edu/u?id=849053.214f550f57fa54a976b5f2d087b6d379&n=T&l=monster_menus&o=714637

(It may be necessary to cut and paste the above URL if the line is broken)

or send a blank email to [hidden email]

---

You are currently subscribed to monster_menus as: [hidden email].

To unsubscribe click here: http://lists.middlebury.edu/u?id=685503.6b071f880fe6a965a128164e6d09ea81&n=T&l=monster_menus&o=714639

(It may be necessary to cut and paste the above URL if the line is broken)

or send a blank email to [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Lock icons in MM navigation menu?

Jay Dansand
In reply to this post by Hilary Caws-Elwitt

I was wrong.

 

It looks like Amherst is using something like a template_block_view_alter() hook. When we did that sort of thing previously, we used CSS-generated content based on those classes, so that’s where my original answer came from. My apologies!

 

Dan’ll definitely have a better suggestion, but you could hack something in via:

function THEME_block_view_alter(&$data, $block) {

  if ($block->module == 'monster_menus') {

    // "New Sub-section" block is delta "1".

    if ($block->delta == '1') {

 

 

Here’s an example REGEXP we use in that exact hook to add “active” classes to LI.here’s (in order to make it Bootstrap-compatible):

      $data['content']['#markup'] = preg_replace('/(<li[^>]+class="[^"]*here)/i', '\\1 active', $data['content']['#markup']);

 

I’m betting without too much work that could be tweaked to inject an <IMG> if you didn’t want to go the CSS-generated-content approach.

 


-- 
Jay Dansand '08
Senior Web Application Developer
Technology Services, Seeley G. Mudd Library
Lawrence University
Appleton, WI
920-832-6585
[hidden email]

From: Jay Dansand [mailto:[hidden email]]
Sent: Friday, April 17, 2015 3:38 PM
To: Monster Menus Development
Subject: RE: Lock icons in MM navigation menu?

 

Dan, correct me if I’m wrong, but those are simply added via the classes “not-world” (not everyone-readable) and “denied,” which you should have in your links already.  I think you could just do the same in your own CSS.

 


-- 
Jay Dansand '08
Senior Web Application Developer
Technology Services, Seeley G. Mudd Library
Lawrence University
Appleton, WI
920-832-6585
[hidden email]

From: Hilary Caws-Elwitt [[hidden email]]
Sent: Friday, April 17, 2015 2:52 PM
To: Monster Menus Development
Subject: Lock icons in MM navigation menu?

 

Hi all,

 

Dan’s probably the best person to answer this, but maybe others are doing it differently and/or would like to implement it too? At the Amherst College site, there’s a nifty feature of the MM tree navigation menu, where the lock icon indicates login required, unlock means restricted but viewable because you’re logged in, etc. (See https://www.amherst.edu/offices/human_resources for an example). We would love to investigate adding something like this, but I don’t see a hook to give access to the rendering (hook_mm_browser_links_alter exists for the tree browser but I can’t find an equivalent). And theme_menu_tree / theme_menu_item_link don’t seem to touch it (because it’s not a Drupal menu exactly, right?) Any suggestions?

--

Hilary Caws-Elwitt

IT Analyst - Five Colleges, Inc. - http://www.fivecolleges.edu

97 Spring St, Amherst MA 01002

[hidden email] - 413-542-4022

 

---

You are currently subscribed to monster_menus as: [hidden email].

To unsubscribe click here: http://lists.middlebury.edu/u?id=849053.214f550f57fa54a976b5f2d087b6d379&n=T&l=monster_menus&o=714637

(It may be necessary to cut and paste the above URL if the line is broken)

or send a blank email to [hidden email]

---

You are currently subscribed to monster_menus as: [hidden email].

To unsubscribe click here: http://lists.middlebury.edu/u?id=849053.214f550f57fa54a976b5f2d087b6d379&n=T&l=monster_menus&o=714639

(It may be necessary to cut and paste the above URL if the line is broken)

or send a blank email to [hidden email]

---

You are currently subscribed to monster_menus as: [hidden email].

To unsubscribe click here: http://lists.middlebury.edu/u?id=685503.6b071f880fe6a965a128164e6d09ea81&n=T&l=monster_menus&o=714640

(It may be necessary to cut and paste the above URL if the line is broken)

or send a blank email to [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Lock icons in MM navigation menu?

Dan Wilga-2
In reply to this post by Hilary Caws-Elwitt
We actually use a theme_mm_get_renderer() hook. Here's the code from our
"default" theme's template.php:


function default_mm_get_renderer() {
   if (!class_exists('amh_mmRenderer')) {
     module_load_include('inc', 'monster_menus', 'mm_renderer');
     class amh_mmRenderer extends mmRenderer {
       private $is_first_leaf;

       public function __construct() {
         $this->is_first_leaf = TRUE;
         return parent::__construct();
       }

       public function prefix_all() {
         return '<ul class="menu">';
       }

       public function prefix_leaf($leaf, $item, $link_item) {
         $return = '<li class="' . $this->state_class($leaf) . '">';
         return $return;
       }

       public function link_leaf($leaf, $item, $link_item) {
         global $user;

         $atts = !empty($item['description']) ? array('title' =>
$item['description']) : array();

         if ($link_item['path'] != $_GET['q'] &&
             ($leaf->state &
(MM_GET_TREE_STATE_EXPANDED|MM_GET_TREE_STATE_HERE)) ==
(MM_GET_TREE_STATE_EXPANDED|MM_GET_TREE_STATE_HERE))
           $atts['class'] = array('active');

         if ($leaf->state & MM_GET_TREE_STATE_HIDDEN) $item['title'] .=
' ' . t('(hidden)');

         $img = '';
         if ($leaf->state & MM_GET_TREE_STATE_DENIED) {
           $atts['rel'] = 'nofollow';
           $icon_title = t('Restricted.');
           $img = '<img src="' .
url('sites/all/themes/default/images/restricted_icon.png') . '" title="'
. $icon_title . '" alt="' . $icon_title . '" width="6" height="8"
class="menu-locked">';
         }
         else if ($user->uid && $leaf->state &
MM_GET_TREE_STATE_NOT_WORLD) {
           $icon_title = t('Restricted; viewable to you after login.');
           $img = '<img src="' .
url('sites/all/themes/default/images/restricted_icon_unlocked.png') . '"
title="' . $icon_title . '" alt="' . $icon_title . '" width="8"
height="8" class="menu-unlocked">';
         }

         if ($this->is_first_leaf) {
           $atts['class'][] = 'not-slide';
         }
         $out = l(check_plain($item['title']) . $img,
$link_item['path'], array('attributes' => $atts, 'query' =>
isset($item['query']) ? $item['query'] : NULL, 'html' => TRUE));

         if ($this->is_first_leaf) {
           $atts['class'] = array();
           $out .= '<a href="#leftcolumn
.mm-calendar-left-nav,#leftcolumn .open-slide~ul,#leftcolumn
.open-slide-title" class="open-slide">' . check_plain($item['title']) .
$img . '</a><div class="open-slide-title">' . l($item['title'],
$link_item['path'], array('attributes' => $atts, 'query' =>
isset($item['query']) ? $item['query'] : NULL)) . '</div>';
           $this->is_first_leaf = FALSE;
         }

         return $out;
       }
     };
   }

   return new amh_mmRenderer();
}

---
You are currently subscribed to monster_menus as: [hidden email].
To unsubscribe click here: http://lists.middlebury.edu/u?id=685503.6b071f880fe6a965a128164e6d09ea81&n=T&l=monster_menus&o=714708
or send a blank email to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Lock icons in MM navigation menu?

Hilary Caws-Elwitt
In reply to this post by Hilary Caws-Elwitt
Fabulous! Thanks, Dan and Jay!

--
Hilary Caws-Elwitt
IT Analyst - Five Colleges, Inc. - http://www.fivecolleges.edu
97 Spring St, Amherst MA 01002
[hidden email] - 413-542-4022

-----Original Message-----
From: Dan Wilga [mailto:[hidden email]]
Sent: Monday, April 20, 2015 10:09 AM
To: Monster Menus Development
Subject: Re: Lock icons in MM navigation menu?

We actually use a theme_mm_get_renderer() hook. Here's the code from our
"default" theme's template.php:


function default_mm_get_renderer() {
   if (!class_exists('amh_mmRenderer')) {
     module_load_include('inc', 'monster_menus', 'mm_renderer');
     class amh_mmRenderer extends mmRenderer {
       private $is_first_leaf;

       public function __construct() {
         $this->is_first_leaf = TRUE;
         return parent::__construct();
       }

       public function prefix_all() {
         return '<ul class="menu">';
       }

       public function prefix_leaf($leaf, $item, $link_item) {
         $return = '<li class="' . $this->state_class($leaf) . '">';
         return $return;
       }

       public function link_leaf($leaf, $item, $link_item) {
         global $user;

         $atts = !empty($item['description']) ? array('title' =>
$item['description']) : array();

         if ($link_item['path'] != $_GET['q'] &&
             ($leaf->state &
(MM_GET_TREE_STATE_EXPANDED|MM_GET_TREE_STATE_HERE)) ==
(MM_GET_TREE_STATE_EXPANDED|MM_GET_TREE_STATE_HERE))
           $atts['class'] = array('active');

         if ($leaf->state & MM_GET_TREE_STATE_HIDDEN) $item['title'] .=
' ' . t('(hidden)');

         $img = '';
         if ($leaf->state & MM_GET_TREE_STATE_DENIED) {
           $atts['rel'] = 'nofollow';
           $icon_title = t('Restricted.');
           $img = '<img src="' .
url('sites/all/themes/default/images/restricted_icon.png') . '" title="'
. $icon_title . '" alt="' . $icon_title . '" width="6" height="8"
class="menu-locked">';
         }
         else if ($user->uid && $leaf->state &
MM_GET_TREE_STATE_NOT_WORLD) {
           $icon_title = t('Restricted; viewable to you after login.');
           $img = '<img src="' .
url('sites/all/themes/default/images/restricted_icon_unlocked.png') . '"
title="' . $icon_title . '" alt="' . $icon_title . '" width="8"
height="8" class="menu-unlocked">';
         }

         if ($this->is_first_leaf) {
           $atts['class'][] = 'not-slide';
         }
         $out = l(check_plain($item['title']) . $img,
$link_item['path'], array('attributes' => $atts, 'query' =>
isset($item['query']) ? $item['query'] : NULL, 'html' => TRUE));

         if ($this->is_first_leaf) {
           $atts['class'] = array();
           $out .= '<a href="#leftcolumn
.mm-calendar-left-nav,#leftcolumn .open-slide~ul,#leftcolumn
.open-slide-title" class="open-slide">' . check_plain($item['title']) .
$img . '</a><div class="open-slide-title">' . l($item['title'],
$link_item['path'], array('attributes' => $atts, 'query' =>
isset($item['query']) ? $item['query'] : NULL)) . '</div>';
           $this->is_first_leaf = FALSE;
         }

         return $out;
       }
     };
   }

   return new amh_mmRenderer();
}

---
You are currently subscribed to monster_menus as: [hidden email].
To unsubscribe click here: http://lists.middlebury.edu/u?id=1034715.d8dc340b0014c740c37e95754e54e1f3&n=T&l=monster_menus&o=714708
or send a blank email to [hidden email]

---
You are currently subscribed to monster_menus as: [hidden email].
To unsubscribe click here: http://lists.middlebury.edu/u?id=685503.6b071f880fe6a965a128164e6d09ea81&n=T&l=monster_menus&o=714710
or send a blank email to [hidden email]
Loading...