It would be desirable to fire the publish/unpublish request over AJAX instead of requiring a page reload. I have attached a patch that allows the administrator to set the views links to do this and will fall back to the normal tokenized request if the user doesn't have JavaScript enabled.

CommentFileSizeAuthor
publishcontent.patch6.1 KBelliotttf
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

AaronBauman’s picture

This sounds like a great feature and well-aligned with the primary focus of this module.
As soon as we get a review or two, I will get this into dev.

Thanks for the patch.

jacobroufa’s picture

This seems to work as intended! The patch didn't though, so I had to add everything manually.

AaronBauman’s picture

Status: Needs review » Needs work

Just tested myself, and came up with a couple issues:

  • it's not enough to just update the text of the publish/unpublish link - the whole view result should be re-triggered. For starters, if there is a "published" column in the view, it will now be out of synch with the "publish/unpublish" link. If the view filters on published, the view will similarly now be out of synch. Further, if node_save has any cascading effects that might effect other rows in the table, affecting the view result, this will no longer be reflected.
    Again -- simple solution -- do an ajax reload on the entire view result.
  • I don't know if a separate "Use AJAX" setting is necessary for this field. Views offers a "use ajax" setting for the whole view -- why don't we just use the global setting?
  • The patch fails to apply because the access callback in the latest version of publish content is split into access callbacks for unpublish and publish operations
patcon’s picture

Perhaps efforts could be merged with these modules:
http://drupal.org/project/views_flag_refresh
http://drupal.org/project/ajax_views_refresh

I've only personally used View flag refresh, but it essentially does what you're looking for, albeit for flag AJAX links :)

patcon’s picture

Reposting from other queues:

This concerns several modules which seem to be seeking similar functionality, so I'm posting an issue in each. Feel free to choose a canonical thread if there's interest is working together :)

http://drupal.org/project/views_flag_refresh
http://drupal.org/node/1083574

http://drupal.org/project/ajax_views_refresh
http://drupal.org/node/1083570

http://drupal.org/project/publishcontent
http://drupal.org/node/936090

patcon’s picture

Oh hey, and in the meantime, if you just want a AJAX publish/unpublish functionality for the view only, then you can set a flag that essentially acts as a publish/unpublish flag, and use views_flag_refresh to "X" items out of a view (assuming you have a filter set so that only publish-flagged items are shown :)

UPDATE: Also, didn't realize this before, but it seems Flag has Rules integration, so it seems you could create a pseudo-publish flag, and have rules publish and unpublish a node depending on how the flag is set. I'll have to true it out!

kirkcaraway’s picture

I started working on this method listed in this thread, and then stumbled across Fasttoggle, which does the same thing: http://drupal.org/project/fasttoggle

Very easy, very quick to set up, but limited compared to Publish Content. It just does the node links via ajax, that's it.

Simon Georges’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

All feature requests should go to current branch, as the 6.x-1.x version is not maintained any more.

jas1988’s picture

Issue summary: View changes

Any updates on issue ! Have someone managed to make it work like this.