By Clément on
Hello,
I would like to view the report from contextual links to nodes and taxonomy when I made the listing.
Not finding what to do, I create a temporary basis ...
/**
* Contextual links
*/
function get_contextual_links($id, $type = 'node') {
global $user;
$output = '';
if(!isset($user->roles[1])) { // Si utilisateur enregistré:
switch($type) {
case 'node':
$links = array('edit' => 'node/'.$id.'/edit', 'delete' => 'node/'.$id.'/delete');
break;
case 'taxonomy':
$links = array('edit' => 'taxonomy/term/'.$id.'/edit');
break;
}
$items = array();
foreach($links as $k => $v) {
if(menu_get_item($v)) {// Si permission
$items[] = l(t($k), $v, array('query' => array('destination' => $_GET['q'])));
}
}
if($items) {
$output .= '<div class="contextual-links-wrapper">';
$theme_args = array('items' => $items, 'type' => 'ul', 'attributes' => array('class' => array('contextual-links')));
$output .= theme('item_list', $theme_args);
$output .= '</div>';
}
}
return $output;
}
I think there is a more professional and easier to make and I would be interested to know. ;-)
Thank you for your help.
Comments
A couple references
Hi,
Please refer to the following:
http://drupal.org/project/examples
http://drupal.org/developing/modules
Also, I highly recommend you review the source code in your base Drupal installation. The core Drupal implementations are really the best examples.
Thank you for your help! I
Thank you for your help!
I will look carefully at the links you gave me and try to find an example.
Greetings.