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 |
Jump to:
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
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
Can you post example code?
I've created a views-view-field--MYFIELD--value.tpl.php template.
In this file there's:
<?phpprint(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
I have the same problem! Anybody have an idea ?
#4
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
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
Same problem here, argh!