i would like to display the voting widget by just giving the node nid.

something like show_voting_widget($node->nid)

is there a way to do it?

Comments

ingo86’s picture

Assigned: Unassigned » ingo86
Category: feature » support
Status: Active » Fixed

There wasn't. In your version there's no way to do that, you should download vote up down 6.x-1.0-beta6.
Now you can display your widget easily calling vote_up_down_widget_form($node).
Feel free to open this issue again if you need additional help.

Anonymous’s picture

cool, thanks for letting me know, can't wait to try.

Anonymous’s picture

i have seen now it even supports views. nice job.

Status: Fixed » Closed (fixed)

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

tormu’s picture

Version: 6.x-1.0-beta4 » 6.x-1.0-beta6

Hmm - I tried that and it doesn't work when I have the alternative +1 style enabled. The function vote_up_down_widget_form() seems to have a line $style = variable_get('vote_up_down_widget_style_node', 0) == 1 ? 'alt' : '';
BUT I think it should be '_alt' instead of 'alt' in order for the $return = theme("vote_up_down_widget$style", $node->nid, 'node'); to work.

It's the same way in -dev version, too.

EDIT: ok, duplicate of http://drupal.org/node/416308

ManyNancy’s picture

Version: 6.x-1.0-beta6 » 6.x-2.x-dev
Status: Closed (fixed) » Active

Anyone know how to do this in 2.x?

dgastudio’s picture

+1

zmove’s picture

+1 for the 2.x version. I don't find an easy and quick equivalent of vote_up_down_widget_form($node)...

Shame, user karma only works with the 2.x version of this module, so I can't change.

dgastudio’s picture

solved via contemplate...

Moscow’s picture

I also wonder how to move the widget beneath the node content for 6.x-2.x-dev. Have searched heavily, but found nothing.

dgastudio’s picture

<?php print $node->content['vud_node_widget_display']['#value'] ?>

Moscow’s picture

Thanks, kervi

one problem solved - the widget showed up. But a couple of new appeared. I added this code to my node-review.tpl.php

print $content

print 'Share some respect with the user if the post was helpful: '. $node->content['vud_node_widget_display']['#value']

1) It seems it is not possible to switch off the display of the main widget via admin interface. So now I have 2 widgets of course.
2) when I add a vote +1 is added up to the "main" widget, but the one I added still shows "0".

Any ideas?

ps. the vote count in the newly added widget adds up only upon page refresh.
pps. I did not find how to hide the widget on anonimous posts. Shall I use tpl.php file for this or is there a better way?

dgastudio’s picture

1. try to display everything as custom cck field: for example to print body: print $node->content['body']['#value']
2. look 1. :)

off’s picture

And how to display widget for comment?

marvil07’s picture

Status: Active » Fixed

Yep, vud widget is shown on node template as part of $content variable.

So, if you want to custom how and where to show the widget, you need to render manually each part of the standard node $content variable (fields, body, etc)

So probably you want to:


// save the rendered value of the widget
$vud_widget = $node->content['vud_node_widget_display']['#value'];
// avoid show it twice
unset($node->content['vud_node_widget_display']);

// render each value inside $content
print $node->content['body']['#value'] ;

// print vud widget, here is the place where we want to show it
print $vud_widget

// render more values inside $content

Status: Fixed » Closed (fixed)

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

meustrus’s picture

Status: Closed (fixed) » Active

That works great for nodes, but there is no such simple fix in comments.

meustrus’s picture

Can I please get a solution for comments? This is kind of important for my theme. An alternative (which would be better for nodes too) is if the "votes" hook in the vud theme could display the whole widget in the links.

marvil07’s picture

Title: How to display voting widget by API? » How to display voting widget by API for nodes?
Assigned: ingo86 » Unassigned
Status: Active » Closed (fixed)

please open a new issue for comments. I think I going to maintain a handbook or include this as part of the README.txt FAQ section since many people ask it.

ndwilliams3’s picture

This is a good fix for a simple content type, but what about when you have numerous content types and numerous fields. It could be quite consuming setting up the node templates. I like the idea of including in the $links.

dreamdust’s picture

I've posted a patch for 6.x-2.1 that allows you to choose whether to display the voting widget in comment body or links. See: #791082: Let separate voting widget from $comment->comment

dreamdust’s picture

Version: 6.x-2.x-dev » 6.x-2.1
Category: support » feature
Status: Closed (fixed) » Needs review
StatusFileSize
new4.04 KB

Also, here is a patch (6.x-2.1) for nodes as well, which enables the user to choose whether to display the voting widget in node content or links.

This is a cleaner solution because it keeps logic out of the templates.

Status: Needs review » Needs work

The last submitted patch, vud_node.patch, failed testing.

ManyNancy’s picture

Yep +1 on $links

dreamdust’s picture

Title: How to display voting widget by API for nodes? » Display widget and votes in body or $links
Component: User interface » Code
Assigned: Unassigned » dreamdust
Status: Needs work » Needs review
StatusFileSize
new11.48 KB

This is an updated patch, for both nodes and comments.

This patch creates the option for users to choose whether to display the voting widget in node/comment content or links. It also adds a new permission for vud_comments 'view votes on comments' that allows you to separately control the display of widget or vote total.

This is tested against the latest 6.x-2.x-dev snapshot. If it works it's ready to be ported and included in the 6.x-2.2 release.

Note: For separate control of the widget and votes display, your widget should be configured to use a separate template for votes and widget in your widget.inc file:

function vud_plain_vud_widgets() {
  return array(
    'title' => t('Plain'),
    'widget template' => 'widget',
    'votes template' => 'votes',
  );
}
dreamdust’s picture

SORRY disregard that last patch, it's backwards. I accidentally reversed the original and patched versions.

Status: Needs review » Needs work
dreamdust’s picture

Version: 6.x-2.1 » 6.x-2.x-dev
Status: Needs work » Needs review
StatusFileSize
new11.47 KB

Here's the latest patch. To re-cap what this patch does:

  • New permission "view votes on comments."
  • New admin setting to control display of voting widget.
  • Changed votes display admin setting to control display for the number of total votes.
  • Options for the display of widget and votes total are "Content," "Links," and "None."

Tested on my 6.19 install. If others can test and confirm let's get this added into the next 6.x-2.x release. I'll also port it to 6.x-3.x if all goes well.

marvil07’s picture

Title: Display widget and votes in body or $links » How to display voting widget by API for nodes?
Component: Code » User interface
Assigned: dreamdust » Unassigned
Category: feature » support
Status: Needs review » Closed (fixed)

please do not hijack the issues, thanks for the patches, but this issue was a support request, not a feature one.

ManyNancy’s picture

@dreamdust ehrm, please create a new issue. I would really like to see your patch in the module. Thanks.