I ported it form 1.x to 2.x, seems to be working all right.

Just have to apply the patch and extract the other files inside a /views directory (I was trying to fight cvs to make an all-in-one patch, but I was defeated).

Comments

franz’s picture

Title: VIews Field Widget » Views Field Widget
franz’s picture

StatusFileSize
new10 KB

update, now with permission check

vanderlip’s picture

I am using WinZip to try to unzip the views.gz file. I think it should work with WinZip, but I get an "Invalid Archive Directory" error message from Winzip when unzipping the file.

franz’s picture

The file is working, I just tested it. I don't know which software you should use in windows, thought... =/

vanderlip’s picture

Status: Needs review » Closed (fixed)

Thanks franz. I found a tool to unzip the file on Windows.

jon nunan’s picture

Status: Closed (fixed) » Needs work

Not sure why this issue got closed, its not in the 2.x branch yet as far as I can tell.

Installed the patch on the current 2.x Dev version, but the widget only seems to show up if I have selected the 'default' widget on the vote up/down settings page.

franz’s picture

Anyways, I changed some things and added some access control to the handler

This goes inside VUD views/ folder

AntiNSA’s picture

+1

marvil07’s picture

nice addition :-)

Some details:

- I think this change is for vud_node, so the relevant place to implement api would be vud_node. But maybe we can make this generic for all vud submodules
- it would be great if you use the new way of theming the widget(to let theme suggestions be used), take a look to the theme calls at the actual module.

ManyNancy’s picture

Unfortunate close. Thanks for the widget.

joecanti’s picture

Thanks - great addition... Patch doesnt seem to go clean on the latest dev with patching software like Eclipse, but was applied manually with no problems and works great!

Will this be comitted to 2.x?

Thanks again, Joe

franz’s picture

Status: Needs work » Needs review
StatusFileSize
new682 bytes
new1.19 KB

marvil07, in the patch #7 I used the theme function I saw on vud_node_nodeapi(). Is that adequate?

I changed the whole patch to be used on vud_node. Haven't tested it yet.

Desi Raaj’s picture

noob question...how do i use this patch file... i understand that i have to extract the files in the views folder but what about the other one?

joecanti’s picture

patching can be quite difficult at first - if your on windows you can use a software called Eclipse to do it. There are a few guides somewhere on Drupal.org.

First, download the .patch file by right clicking then save link as.

If you open it up you can see the '+' lines are added and the '-' lines are subtracted - from the module listed above them.

You could do it manually, which is useful to know for small patches - but for larger patches you will want to use software...

Basically, you download Eclipse, then create a new project, then import the original files to be patched into that project.

Then click on project > apply patch, then choose your patch, then choose which files are to be patched from your workspace, and then the software will try to match them up and do the patching.

The new files will be stored wherever the Eclipse project is stored - usually c:\users\workspace\myprojecthere etc etc

Good luck!

franz’s picture

If you use a Linux, just go into the module folder, copy the patch to ita and on a terminal type

patch < patch_file

;)

You can boot a LiveCD, it might take lesser time than installing Eclipse...

franz’s picture

I also heard of a patch.exe which works fine on Windows... try to Google that!

marvil07’s picture

@Desi Raaj: The official documentation http://drupal.org/patch ;-)

Desi Raaj’s picture

Thank you so much, i will give a try tomorrow and report back. i'm windows btw. Thank You.

marvil07’s picture

Title: Views Field Widget » expose widgets as views fields
Issue tags: +views integration
StatusFileSize
new4.18 KB

I just made this changes a one-patch-file to make it easy to test.

marvil07’s picture

Status: Needs review » Needs work

I really want to make this change, but I would like to commit it when we have support for nodes, terms and comments.

I tried it, but not luck, so let me suggest about the raw patch:

+++ vud_node/views/views_handler_field_vote_up_down_widget.inc
@@ -0,0 +1,62 @@
+// $Id: ¶

use $Id$

+++ vud_node/views/views_handler_field_vote_up_down_widget.inc
@@ -0,0 +1,62 @@
+        /* ¶
+        $widget_message = t('Sorry, there was problem on the vote.');
+        if (!$can_edit) {
+          $widget_message = t('You are not allowed to vote.');
+        }
+        else if (!$vote_on_teaser) {
+          $widget_message = t('Please go to full version of this content to vote.');
+        }
+        drupal_add_js(
+          array(
+            'vud_node' => array('widget_message' => $widget_message),
+          ),
+          'setting'
+        );
+        // */

we need to change that to make this compatible to the new way to pass message: passing it to vud_widget theme function. More information about it on #807928: Use modal div instead of popup at denying vote

+++ vud_node/views/vud_node.views.inc
@@ -0,0 +1,40 @@
+// $Id:

$Id$

+++ vud_node/views/vud_node.views.inc
@@ -0,0 +1,40 @@
+  $data['vote_up_down']['table']['group'] = t('Vote up down');
+  $data['vote_up_down']['table']['join'] = array(
+    '#global' => array(),
+  );

Not sure about it, but since we do not have tables, we do not need this.

In the other hand please use Vote Up/Down as the group name

+++ vud_node/views/vud_node.views.inc
@@ -0,0 +1,40 @@
+  $data['vote_up_down']['widget'] = array(
+    'title' => t('Vote Up Down Widget'),
+    'help' => t('Provide a widget for voting up/down.'),
+    'field' => array(
+      'handler' => 'views_handler_field_vote_up_down_widget',
+    ),
+  );

A general comment, IMO we want to use vud instead of vote_up_down for namespace.

+++ vud_node/vud_node.module
@@ -293,3 +293,14 @@ function vud_node_link($type, $object, $teaser = FALSE) {
+/**
+ * Function for integrating with views 2
+ */

please use "Implementation of hook_views_api()."

Powered by Dreditor.

franz’s picture

I really want to make this change, but I would like to commit it when we have support for nodes, terms and comments.

That would require more work, but after fixing major issues with vud_node patch, shouldn't be that hard...

we need to change that to make this compatible to the new way to pass message: passing it to vud_widget theme function. More information about it on

This is not just badly documented, but the argument is not even on hook_theme implementation. There is an argument with a message_code, which defaults to an error, please clarify this

marvil07’s picture

This is not just badly documented, but the argument is not even on hook_theme implementation. There is an argument with a message_code, which defaults to an error, please clarify this

About the specific issue you mention, I created #821048: make widgets easy to theme

About just badly documented, please provide real feedback, with specific details and/or patches to make docs better. Just say it do not help so much.

Donngal’s picture

i applied the patch and the .inc file in my VUD views folder, but i cant find a "VUD Widget" field in views, did i misunderstood this patch?

marvil07’s picture

Donngal: please notice the status is "needs work", also notice I mentioned in #20 the patch is not working. So feel free to provide a new verison of the patch ;-)

franz’s picture

About just badly documented, please provide real feedback, with specific details and/or patches to make docs better. Just say it do not help so much.

As much as you requested this patch to conform to some new rules with no details, I requested better info on that, believing that the developer is the one that understands his own code better. That's all, and as you see, I did provide very specific inquiries about the new theme function.

franz’s picture

Donngal: The widget should pop out anyway, even with the problems that still require work, which patch did you apply?

Donngal’s picture

I applied the one from comment #12

dixon_’s picture

Status: Needs work » Needs review
StatusFileSize
new3.46 KB

Here is an updated patch that meets all of the comments from #20 plus some more cleanup and optimization.

snecci’s picture

Category: feature » support

What should happen after applying the patch #28? I did the following:
1. Fresh install vote_up_down-6.x-2.0-beta1
2. Apply patch #28 in the path modules/vote_up_down/vud_node with the command patch < 660258-vud-views-integration-28.patch
3. move the new files vud_handler_field_widget.inc and vud_node.views.inc to a new folder modules/vote_up_down/vud_node/views

hmm.. what should I happen next? I cannot find any new options under views... Thanks.

marvil07’s picture

Category: support » feature

snecci: issues categories do not use to change, so I'm moving it back to feature request, that is the actual category of the issue. For more reference take a look at Issue submission form fields.

Donngal’s picture

subscribe, would like to get this working.

dixon_’s picture

@snecci You must apply the patch in the root directory of the main vud module. The folder where vud.module is located.

snecci’s picture

Thanks marvil07 and dixon_.

I applied the patch in the root directory. I guess my mistake was that I was not adding the -p0 option.

so now I did:
modules/vote_up_down$ patch -p0 < 660258-vud-views-integration-28.patch

It seems to patch the files correctly and I can see the VUD Widget under fields while creating a view, but I still cannot see the widget, just the label.

Any clues? Thanks.

marvil07’s picture

Here it's an updated patch that use hook_views_data_alter() instead of hook_views_data() to avoid show this views field on not-node views. Also fixing some little naming errors.

It seems to work, for vud_node, now let's make this possible for terms and comments.

jthomasbailey’s picture

I gave it a try:

patch < fields.patch
patching file vud_node.views.inc
patching file vud_node_handler_field_widget.inc
can't find file to patch at input line 104
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git vud_node/vud_node.module vud_node/vud_node.module
|index 8db6fac..51464f7 100644
|--- vud_node/vud_node.module
|+++ vud_node/vud_node.module
--------------------------

So I tell it to patch vud_node.module...

File to patch: blah/blah/sites/all/modules/vote_up_down/vud_node/vud_node.module 
patching file blah/blah/sites/all/modules/vote_up_down/vud_node/vud_node.module

And nothing happened. Can't find any new fields or relationships, subscribing.

marvil07’s picture

hobgobbler: do not forget to clear the cache. about the patch it should work using patch -p0 < file.patch

jthomasbailey’s picture

hey hey that time it worked -- I think the "-p0" did the trick

franz’s picture

Here it's an updated patch that use hook_views_data_alter() instead of hook_views_data() to avoid show this views field on not-node views. Also fixing some little naming errors.

This doesn't seem to be adequate, as we are trying to pull off an official integration for views. There is an attribute when implementing hook_views_data that excludes the field from appearing on some base tables...

marvil07’s picture

Re #38: IMHO it _is_ adequate, actually it was a suggestion by merlinofchaos, who I asked for a solution to only show the widget in some views types, while I was trying to make this.
Use exclude make us unable to prevent show on inadequate places, but we _only_ want to show the widget for nodes on node views, and I think the same for terms(only taxonomy views) and the same for comments(only comments views)

marcoBauli’s picture

patch at #34 seems to work fine up to now, thanks marvil07 :)

Donngal’s picture

mhh, id doesnt works at all for me, i get an Error: handler for vote_up_down > widget doesn't exist!

dixon_’s picture

@Donngai You have to clear the cache to have Views read the new handler.

Donngal’s picture

@dixon Sorry, clearing the cache doesnt solves the problem.

Edit: it works fine! made some patching mistakes, and i had to replace the function call "vud_theme_functions" on line 36 in the vud_node_handler_field_widget.inc file with "views_theme_functions".

franz’s picture

re #39: Ok, that's fine. What else is needed for the patches to be commited?

marvil07’s picture

Status: Needs review » Needs work

@franz: thanks for remember me to change the status again. Like mentioned above, I would like to commit this we have support for nodes, terms and comments. Now we have complete node support, so let's do the same for terms an comments.

Anyone feel free to provide a patch, I'll be taking a look to this the next week to push it until committed ;-)

marvil07’s picture

Status: Needs work » Needs review
StatusFileSize
new5.89 KB

support for comments :-)

After this we only left support for taxonomy

marvil07’s picture

to follow integration with vud_term, I need a clarification: #837332: use the right tag for vud_term?

boran’s picture

Subscribe. Tried #34 patch, worked fine for nodes. Thanks.

Desi Raaj’s picture

ok, i have patched this module using the patch in #34, but is there anyway to sort it by the number of votes in views? i have defined a relationship "Node: Vote results" and tried defining a sort criteria "(Vote results) Vote results: Value desc" but it doesn't sort. please help. thank you

(Views Setup) http://img195.imageshack.us/img195/8562/screenshot20100627at122.png
(result) http://img188.imageshack.us/img188/8132/screenshot20100627at123.png

franz’s picture

Hi Desi, most of the work here is to expose the fields properly you can use the widgets on views. The feature you suggest is great also, but I think you could open a new feature request issue for that. First we crawl, then we walk... ;)

Desi Raaj’s picture

awesome, i will do so. thank you

marvil07’s picture

Status: Needs review » Needs work

based on #837332: use the right tag for vud_term?, for vud_term we need to make views_data_alter on node implementation of views_data, because vud_term depend on a nid for its tag.

marvil07’s picture

Title: expose widgets as views fields » Expose widgets as views fields
Status: Needs work » Fixed
StatusFileSize
new10.03 KB

Ok, after re-working vud_term as mentioned and updating code since #821048: make widgets easy to theme I committed this to 2.x and 3.x.

Thanks all!

BTW: I'm going to make a beta2 now ;-)

franz’s picture

Desi, I just checked what you suggested, and I remembered that votingapi expose such sort criteria (Vote results), that should do the work, I think. BTW, did you open any issue about this? If so, please link here for a reference

Nice to know it's finished, marvil07! =)

marvil07’s picture

grenit’s picture

Hi all,

VUD widget does not appear for me after applying #46.

sites/all/modules/vote_up_down# patch -p0 < expose-widgets-as-views-fields_v9.patch
patching file vud_comment/views/vud_comment.views.inc
patching file vud_comment/views/vud_comment_handler_field_widget.inc
patching file vud_comment/vud_comment.module
Hunk #1 FAILED at 193.
1 out of 1 hunk FAILED -- saving rejects to file vud_comment/vud_comment.module.rej
patching file vud_node/views/vud_node.views.inc
patching file vud_node/views/vud_node_handler_field_widget.inc
patching file vud_node/vud_node.module
patching file vud_term/views/vud_term.views.inc
patching file vud_term/views/vud_term_handler_field_widget.inc
patching file vud_term/vud_term.module
Hunk #1 succeeded at 182 with fuzz 2 (offset 10 lines).

I thought this meant success, so I emptied Drupal cache (is this the cache I have to empty?), but I could not use the vud widget in views. Anyway, after this I removed files from vote_up_down/vud_node/views, and applied #34:

sites/all/modules/vote_up_down# patch -p0 < 0001-660258-Added-expose-widgets-as-views-fields.patch
patching file vud_node/views/vud_node.views.inc
patching file vud_node/views/vud_node_handler_field_widget.inc
patching file vud_node/vud_node.module
Hunk #1 succeeded at 58 (offset 10 lines).

VUD widget still does not show up in Fields. What else do I have to do?

ManyNancy’s picture

Patch is included in latest release, just update to latest release?

grenit’s picture

Yes, thank you. Field is now accessible, but actual widget does not show up in table style. Will check later when I have time.

grenit’s picture

Changed nothing, but now widget is displayed. Must have been some cache, maybe browser...(?) As far as I remember I emptied Drupal cache.

grenit’s picture

No, it was user permissions.

avior’s picture

Hi
I have installed 6.x-2.0-beta2 version
i am trying to show comments in a view with the vote widget , i can add the vote widget in views but i see nothing when showing the view
(it's not permission issue because i can see it in the default comment view)

is this patch got into 6.x-2.0-beta2 version or do i need to patch ?

marvil07’s picture

avior: please do not hijack the issue(this is not a support issue), its status is fixed and like mentioned above it is commited to 2.x and 3.x

avior’s picture

Hi @marvil07
My only question was
is this patch got into 6.x-2.0-beta2 version or do i need to patch ?

marvil07’s picture

@aavior: as mentioned in #53 I releades beta2 after commiting this patch

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

fourmi4x’s picture

But this is not on 6.x-3.0-alpha1 ? (can't see it!)

EDIT : Sorry - I misconfigured it... it works fine !