I like the concept of contextual links in D7 and want to push it a bit further: I want views to have an 'Add item' contextual link, so the site administrator can easily add new items.

Of course I could add an 'Add item' button to the view's footer instead. But I need to show it only to users who have the appropriate permission to add items.

Is there an idiomatic way of doing it?

2 Answers 2


Checkout the Custom Contextual Links module. I haven't personally used it but it looks like it does what you're after. It also supports views as of 7.x-1.1.


You can add the following code to the 'views header'.

It provides links to adding new items to the node collection or reordering.

1 Edit view

2 'Add' Global: Text area

3 set text format to 'PHP code'.

4 add the following code.

/* header for list */
global $user;
if (user_access('create document content', $user)) {
  $path = '/news/list';
  $addLink = l(t('Add news'), 'node/add/article', array('query' =>               
  array('destination' => $path)));
  print $addLink;
  $viewLink = l(t('View news'), '/news');
  print $viewLink;
  $listLink = l(t('Edit/reorder news'), '/news/list');
  print $listLink;
  • Yes, this will provide the functionality, just not in the views "contextual links" section on the frontend. That's the name for the on-hover "gear and triangle" styled dropdown shown to administrative users in the top right corner of views etc..
    – tanius
    Commented Mar 18, 2016 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.