Plus1 widget as a field in Views

newmediaist - February 17, 2009 - 17:16
Project:Plus 1
Version:6.x-2.6
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi - Does anyone know how to replicate the layout of collectiveopinions.com - i.e. embed a Plus1 button as a field in the view, which both displays the number of votes and enables for Plus1 voting to occur?

Thank you!

#1

newmediaist - February 20, 2009 - 15:42

One way I have discovered is by calling the widget from the row template for the view, rather then as a field in the view configuration. In order to implement the plus1 button from the template you must first grab the NID from the row data, then get the node object and pass it to the plus1 widget.

#2

merto87 - April 1, 2009 - 11:36
Version:6.x-2.4» 6.x-2.6
Category:support request» feature request
Priority:normal» critical

Can you post example code?

I've created a views-view-field--MYFIELD--value.tpl.php template.

In this file there's:

<?php
print(plus1_jquery_widget($row->nid, $teaser, $page));
?>

The widget is printed, but:
- widget score is same for all fields;
- Vote button doesn't work: the javascript require this path: /plus1/vote/?token=94f8e17c56f5f059d5ea1a0896dce81f&json=true without node_id after arguments.

Thank you very much and sorry for my english!

#3

GMercey - May 18, 2009 - 17:49

I have the same problem! Anybody have an idea ?

#4

voxpelli - May 28, 2009 - 17:29
Priority:critical» normal

This is certainly not a critical issue - while nice to have it is nothing that stops Plus1 from working.

My suggestion would be to use teasers of some form if possible

#5

ximo - July 1, 2009 - 18:33
Title:Create view with Plus1 button embeded, similar to www.collectiveopinions.com/?» Plus1 widget as a field in Views

I've written a small Views field handler for this. It works, but it's not really recommended from a performance perspective. Each plus1_jquery_widget() call needs a node object, and a node_load() call is pretty expensive in a listing.

I could avoid doing a node_load() by passing a fake node object with only the data needed, and I might do just that. If I do, I'll be back with a patch. If not, you're best of doing what voxpelli says, presenting the nodes as teasers and theming that to your needs :)

(Rewrote the title...)

#6

jackiepeters - July 1, 2009 - 22:41

Same problem here, argh!

 
 

Drupal is a registered trademark of Dries Buytaert.