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

Comments

starbow’s picture

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?

gausarts’s picture

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

nwe_44’s picture

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.

nwe_44’s picture

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.

drupalina’s picture

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!

nwe_44’s picture

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

shaynl’s picture

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

nwe_44’s picture

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

looplog’s picture

I may be misunderstanding the OP request, but no extra modules or code are needed to achieve this in views. You can rewrite fields in views as links.

The way I build edit links is by adding a NID field, and using the "Rewrite the output of this field" option combined with the "Output this field as a link" option. The first option allows you to specifiy anything you like as the link text, while the latter allows you to build the link using the NID, or any previously included field, as tokens. For example, comment links can be built with "comment/reply/[nid]#comment-form", and edit links can be built similarly with "node/[nid]/edit?destination=node/[nid]". The link reformatting options are fairly extensive and allow adding as many classes as you like, as well as defining alt text.

edit: I just realized that his may not solve permissions issues, but I'll leave it here for reference.