1 May 2014

This snippet shows you how to create contextual links in Drupal 7. If you don't know what contextual links are then those are the links in front end that come up from the ratchet. contextual links

Source code viewer
  1. /**
  2.  * Implements hook_contextual_links_view_alter().
  3.  */
  4. function HOOK_contextual_links_view_alter(&$element, $items) {
  5. if ($element['#element']['#block']->module === 'HOOK') {
  6. $element['#links']['my-custom'] = array(
  7. 'title' => t('My Custom'),
  8. 'href' => 'admin/structure/my-custom',
  9. 'query' => drupal_get_destination(),
  10. );
  11. }
  12. }
Programming Language: PHP