Views integration

gausarts - November 10, 2008 - 18:13
Project:Popups API (Ajax Dialogs)
Version:6.x-1.1-rc5
Component:Miscellaneous
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

Will this possible to integrate with views by providing a form to inject a class to, perhaps, edit or delete link in views? I have tried to manually add it to say views-view-field--block--edit-node.tpl, but then I had the problem with how to display the output (edit link) only to the node author in views. The regular

global $user; $account = user_load(array('uid' =>$uid)); 

doesn't seem to work with the custom print l(); and popups.

Any plan or idea? Thanks

#1

starbow - November 10, 2008 - 19:59

Sounds like you are on the right track. Doesn't views already have logic to only show the edit link to those with the correct permissions?

#2

gausarts - November 11, 2008 - 08:15

Views does have the logic, only if we provide default print $output (no popups). The edit link will show to the author only. Then it loses its argument when we override that print $output with the suggested print l() by popups.

Hope you can consider this request since popups will always be a great shortcut for edit, add and delete, reply things especially in the views listings, imagine thousands nodes. And so we don't have to override any single views manually anymore. That will be beautiful. Thanks

#3

nwe_44 - May 15, 2009 - 09:07

I'm trying to add a similar feature with on a different tack. I've created a custom module that adds the popup class to each edit field with a JavaScript snippet as follows;

$(document).ready(function() {$('.views-field-edit-node > a').addClass('popups-form');});

This would be elegant, except that it doesn't work, and I'm not sure why. I like this as a solution because going forward I could standardize the implementation across all the sites I build, rather that building a custom template every time. Also, the custom module means that the javascript is called before popups.js gets a chance to process the html. Still not working though. Will report back soon.

#4

nwe_44 - June 14, 2009 - 11:32

I ditched that idea and used the api properly, creating a custom module that calls popups on all views edit links thus

return array(
'*' => array(
'.views-field-edit-node a:contains('. t('edit') .')',

and so on. Hope this helps others.

#5

drupalina - November 2, 2009 - 08:31

Subscribing... Would be great to have popups for the "Edit" and "Delete" links coming from Views, especially when you are trying to set up a user-friendly site for people for whom using Facebook is like rocket-science ;) ... and also because everything in Drupal is now moving in the direction of the Views.

nwe_44, would you be so kind as to share your custom module?

Many thanks!

#6

nwe_44 - November 13, 2009 - 10:54

Most of my module contains code that is not relevent to this issue, but to expand on my previous post, it goes a little something like this;

/**
* Implementation of hook_init().
*/
function MODULE_NAME_init() {
$path = drupal_get_path('module', 'tmc_popups');
// Force loading Wysiwyg to overcome js error
drupal_add_js($base_path .'sites/all/libraries/tinymce/jscripts/tiny_mce/tiny_mce.js', 'module', 'header', FALSE,TRUE,FALSE);
// Force popups module to scann all pages
popups_add_popups();

}
/**
* Implementation of hook_popups()
*
* This implements hook_popups, defined in popups_get_popups.
* See the comments in popups_add_popups for explination of the options.
*
*/
function MODULE_NAME_popups() {
  return array(
'*' => array(
'.views-field-edit-node a' => array(
"updateMethod" => "reload"),
'a.views-field-edit-node ' => array(
"updateMethod" => "reload"),
));
}

Hope this helps

#7

shaynl - December 1, 2009 - 11:40

nwe_44, thanks for sharing this!
Is this code enough to use as a module that calls popups on all views edit links?

#8

nwe_44 - December 3, 2009 - 15:21

not quite, different views styles produce different markup. You'll need to tailor it a bit depending on what type of view you're using

 
 

Drupal is a registered trademark of Dries Buytaert.