Download & Extend

Ability to include/exclude

Project:Admin:hover
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:conortm
Status:active

Issue Summary

We use this module because it makes things very easy for our clients to edit their site content (including blocks with text). However, since the edit links appears on all blocks (including the primary links, views blocks etc.) it gets a bit confusing. The client can then see the edit link, press edit, but not edit anything there (if it's a views block for example), because they don't have the permission to actually edit the content of those blocks.

We'd really like the ability to include/exclude certain blocks from getting admin:hover links, perhaps via css selectors, or simply via block settings.

Comments

#1

Assigned to:Anonymous» conortm

Thanks, insats! I will definitely work on adding this feature. As you can see, I have some other bugs to work out first. Stay tuned...

#2

Here's a template.php snippet I created to exclude admin:hover links from specific node types. It loads the node object, so it could be easily adapted to do more.

Add this to your template.php, replace THEMENAME with the name of your theme, and clear all caches. You should no longer see admin:hover on panel nodes (or whatever you specify in $exclude).

<?php
/**
* Generate the HTML output for a set of admin_hover links.
*
* @param array $links
*   An array of admin_hoverlinks.
* @param array $attributes
*   An array Drupal attributes applied to the containing div.
* @return string
*   HTML to print to screen
*/
function THEMENAME_admin_hover_links($links, $attributes) {
 
// Define an array of node types to exclude
 
$exclude = array('panel');
 
 
// Search for IDs indicating a node and extract the NID
 
if (preg_match("/^node-([0-9]+)-admin_hover/", $attributes['id'], $matches)) {
   
$nid = $matches[1];
   
$node = node_load($nid);
    if (
in_array($node->type, $exclude)) {
     
// No markup is generated
     
return "";
    }
  }

 
// Otherwise render as normal
 
$output = '';
 
$attributes['style'] = 'display:none;';
 
$output .= '<div'. drupal_attributes($attributes) .'>';
 
$output .= theme('links', $links, array());
 
$output .= '</div>';
  return
$output;
}
?>