Postponed (maintainer needs more info)
Project:
Plus 1
Version:
7.x-1.x-dev
Component:
User interface
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
17 Feb 2009 at 17:16 UTC
Updated:
17 Sep 2014 at 14:07 UTC
Jump to comment: Most recent
Comments
Comment #1
newmediaist commentedOne 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.
Comment #2
merto87 commentedCan you post example code?
I've created a views-view-field--MYFIELD--value.tpl.php template.
In this file there's:
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!
Comment #3
GMercey commentedI have the same problem! Anybody have an idea ?
Comment #4
voxpelli commentedThis 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
Comment #5
ximo commentedI'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...)
Comment #6
jackiepeters commentedSame problem here, argh!
Comment #7
marcoka commentedusing views with plus1 has crumbled my concept :). i have that problem now, too
Comment #8
dakotaryan commentedRan into this same issue, and am not sure how to fix within the module itself. However, I found a hacky solution using Views Custom Field, which will let you customize the results of a views query.
Specifically, I used the following code in the PHP code customfield:
And the following code I added into my theme's template.php:
I also commented out the following line the jquery.plus1.js (since I'm handling it differently):
//plus1_widget.find('.'+ Drupal.settings.plus1.score_class).hide().fadeIn('slow').html(json.score);and in order to have the context-based messages appear when the JSON loads, you'd have to play around some more with the JS. Not my goal.
Probably not the most efficient or elegant solution, but it works and lets me add a live voting widget into a views field, kind of. Hope this will be a viable solution until something cleaner is implemented into the plus1 module. By the way, I'd also love to see context-based messages (aka. 3 other users liked this) supported and customizable out of the box.
Cheers, Dakota
Comment #9
joeshock commented@dakotaryan
Great post and ideas. I just implemented your suggestions and they work great. One thing I added however was the ability for you to go back to the page from which you voted with a simple addition of &destination=$_SERVER["REQUEST_URI"] at the end of the vote link url.
So all I updated was the code that goes into the template.php file, which is below:
Comment #10
joeshock commented@dakotaryan
here's another idea to consider. try this one out if you want. it's what might work for me in the site i'm building.
Comment #11
joeshock commentedSaw this other module that might be better as an option. It's called Drupal It. Works out pretty well, however there is one downside I've encountered and it seems that you have to be an authenticated user to vote. Sticking with the Plus1 setup, but just throwin this one out there too.
http://drupal.org/project/drupalit
Only thing you have to figure out by Googling a little bit is how to "manually" place this system within a view. Just place this anywhere within your view after configuring the DrupalIt settings to "manual" and you'll be all set.
Comment #12
sebsebseb123 commentedHi All.
I'm using a views tpl.php file to customize my views output. I wanted to manually embed the plus1 widget, but I had the same problem you're all having....same score, unable to vote...etc... I looked into the plus1_jquery_widget() function... Turns out the first parameter is NOT a node_id value. But rather, the entire node.
So, going back to comment #2, where the nid is sent:
It should be this instead:
Comment #13
eelkeboezeman commentedthis last suggestions worked brilliantly. thanks!
Comment #14
joeshock commentedworked for me too
Comment #15
joeshock commentedComment #16
thelionkingraja commentedplease send me the worked solution with step by step process.
Comment #17
webthingee commentedMy quick and easy consisted of. combining...
#8 - "I found a hacky solution using Views Custom Field, which will let you customize the results of a views query."
- - installed Views Custom Field.
- - added a php field.
#12 - used this code, but changed $row to $data.
so far so good...
Comment #18
nancydruIs there a patch or anything here?
Comment #19
Weka commentedsubscribe
Comment #20
drupalninja99 commentedIn my view I am using a views custom php field with:
And that works pretty good, it seems like plus1 could expose that very thing itself. The only issue is that in plus1 1x it did ajax, now it does a redirect.
Comment #21
nancydruIt was changed from Ajax because of #322735: Vote link is executed by search engines. I don't understand Views coding very well, so someone will have to submit a patch and have it RTBC'ed.
Comment #22
justinlevi commentedI was able to get this to work in my D7 views-view-fields--VIEWNAME.tpl.php file as follows:
Comment #23
nancydruThanks.
Comment #24
WhatUp commentedHi!
Could someone please explain how to do this in Drupal 7? The Views Custom Field module only exists for D6.
A up to date description would be great!
Regards.
Comment #25
federico commentedHi, I'm trying to do this in D7, could someone help?
My view is called "viewname". I create a new file on /sites/all/themes/mytheme/templates called "views-view-fields-viewname.tpl.php" and pasted this code in it:
Should I use
delimiters?- I go to /admin/structure/views/view/links/edit
- I Click on fields > add and search for something like "widget", but I don't find anything.
I copy the file views-view-fields-viewname.tpl.php to /sites/all/modules/views/theme and repeat the procedure, but I still can't find the new field.
I'll appreciate any help. Thanks in advance.
Comment #26
exlin commentedProper views integration (d7-3.x) would be great.
Including field for sorting and fields.
Maybe preferred way in d7 is to use fields for this...
Comment #27
AndyThornton commenteddrupal's comment need to implement "+1". I give a +1 to #20 ... works perfectly and seems like the right and most elegant solution.
Comment #28
shashi_lo commented#17 Was exactly what I was looking for. Thanks!
Comment #29
FR6 commentedNot sure if it's the best way to do but what I did to display the Plus 1 widget in a view is:
In my file views-view-fields--MyView.tpl.php:
I'm using Drupal 7.31 with plus1-7.x-1.0-alpha2.