how to display vote widget from tpl.php ?

kalashari - April 24, 2007 - 18:23
Project:Node Vote
Version:5.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:macm
Status:active
Description

yep, I am using custom CCK content type (usernode) and would like to display voting widget from usernode? Is there a way to do this or am I missing something?

thanks,

k.

#1

kbahey - April 25, 2007 - 03:06
Status:active» closed

There are two themable functions that you can use in template.php.

function theme_nodevote_display_vote($vote_data)
function theme_nodevote_do_vote($node)

#2

kalashari - May 6, 2007 - 00:45

is it possible to have voting form displayed all inline? Like to have dropdown box, then right next to it to have submit button... This would really be helpful.

#3

macm - May 16, 2007 - 20:20
Assigned to:Anonymous» macm
Status:closed» active

I am looking for this too.

For example:
If I have a page-node.tpl.php how can I insert Nodevote into this page? In my custom theme, nodevote isnt show neither in page-default.tpl.php (from original page.tpl.php) but if I switch themes for example to bluemarine NodeVote works like a charm.

Or better

If I create a Views (and there I have have nid) How can I insert NodeVote into this views?

Which form I need call? I tried

print drupal_get_form('nodevote_rate_form', $node);
print drupal_render($form['nodevote_rate_form']['nid']);?>

A lot of people are looking for a way to custom nodevote. Khalid tell us the trick? or just tell "it is not possible"!

Could you tell if nodevote have a markup to appear? Which?

I had custom some "function theme_..." and remove some markup from core (I know isnt appropriate but some times Drupal have a lot of markups) could this affect Nodevote? ( I remove div .'content' class markup)

Regards and Congratulations NodeVote and UserPoints are amazing. Thanks for all.

#4

kalashari - May 17, 2007 - 00:42

for current value of a voting on a node, I use:

<?php
echo $node->content['nodevote_display']['#value'];
?>

for display of a voting dropdown box, I use:

<?php
echo $node->content['nodevote']['#value'];
?>

#5

macm - May 17, 2007 - 11:15

Ok,

I think to insert nodevote into a page-node.tpl.php you should do this.

print theme_nodevote_do_vote($node);

I tested and the vote is created into table nodevote.

I tried get vote results of the node using "print theme_nodevote_display_vote($vote_data);" but didnt work. (I tried a lot of ways inclusive theme_mynodevote_display_vote($vote_data) into my template.php)

So I think the best way will be create a custom db_query into de page.

Hope be useful.

Regards

#6

jsethi - October 22, 2007 - 20:43

I tried using:

if ($node->nodevote->vote_display) {
   $data = _nodevote_get_vote_data($node->nid, $page);
   print theme('nodevote_display_vote', $data['score'], $data['votes'], $data['vote_display']);
}

However when my #of votes show as the score i last submitted and I can only see the stars on a score of 2...

I am using the following code to submit the vote (based on what others have told me to use):

if ($node->nodevote->vote_do) {
   print theme('nodevote_do_vote',$node);
}

Does anyone know why my votes are not working?

#7

vincentw - November 22, 2009 - 07:45

if you use

<?php
print drupal_get_form('nodevote_rate_form', $node);
?>

in any node.tpl.php it should work

 
 

Drupal is a registered trademark of Dries Buytaert.