Today I had a task to add nodequeue manipulation contextual links to some view. First I found this blog post, which explains, how to make desired menu items contextual links ready. As Marcus states in his post, I first needed to alter nodequeue menu items:
function MYMODULE_menu_alter(&$items) {
$items['admin/structure/nodequeue/%nodequeue/edit']['context'] = MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE;
$items['admin/structure/nodequeue/%nodequeue/view']['context'] = MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE;
}
Nodequeue admin pages were now ready to be added to any contextual links on site. Since Marcus explains how to alter contextual links on blocks, I had to figure out how to do it with views. Solution turned out to be very simple. Contextual links are added to view in views-view.tpl.php, where $title_suffix is displayed. I just needed to add nodequeue contextual links to that variable (which is a render array in fact).
function MYTHEME_preprocess_views_view(&$vars) {
$vars['title_suffix']['contextual_links']['#contextual_links']['sn_fpmain_news'] = array(
// 3 is queue id in my case; it could be any other page argument
'admin/structure/nodequeue', array(3)
);
}
And here is the result:

Is there any better way to do this?



Comments
Different Way Permalink
Submitted by Chad on Wed, 09/21/2011 - 00:23
Enjoyed reading your method, as it certainly works.
I think you could have made this much easier, though.
To do this you can add an additional field to your view which will display the link to the nodequeue - I used 'All queues' and limited it to my queue(or it can be several queues).
Then, I/we themed the link to appear like views admin links (appear on hover).
In my case the name of the template was views-view-field--nodequeue-all-queues.tpl.php and the code can be something like this:
<code>
<?php $data = $row->{$field->field_alias}; ?>
<?php if(user_access('administer nodequeue')): ?>
<!-- this class is needed here so the link will be auto-hidden/displayed -->
<div class="views-admin-links views-hide">
<?php print t('See The Queue: ').$output; ?>
</div>
<?php endif ?>
</code>
Link to Tutorial : http://www.appnovation.com/making-management-nodecues-views-easier
Permalink
Submitted by slashrsm on Wed, 09/21/2011 - 21:20
thanks for this article, it's Permalink
Submitted by eastvantage on Wed, 09/21/2011 - 09:37
thanks for this article, it's been really informative.
There's a module now that Permalink
Submitted by cruzeazy on Sun, 11/06/2011 - 08:51
There's a module now that helps with this.
http://drupal.org/project/ccl
That's great! I'll definetely Permalink
Submitted by slashrsm on Sun, 11/06/2011 - 19:57
That's great! I'll definetely take a look at it.
Well, the usefulness of Permalink
Submitted by Luis on Thu, 12/01/2011 - 04:40
Well, the usefulness of adding contextual links is very good, seeing the first function a code I found really easy to implement, I tested on my local server and it really works. Excellent contribution friend.
regards
<a href="http://publicidadypaginasweb.com">diseño web mexico</a>
Add new comment