I created a Rate widget and assigned it to one of my content types, but nothing shows up. Could you some one please post a tutorial on how to use this module.

Thanks,
Chompz

Comments

mauritsl’s picture

You have to change the node template in order to let the widget show up. Please see section 3 of the readme file for more information. Please let me know if that works for you.

summit’s picture

So it makes no sense to copy the rate-widget.tpl.php to the theme folder. At least I do not see a result. Could you may be add a pre-fabricated node.tpl.php?
Thanks a lot in advance for considering.

greetings,
Martijn

mauritsl’s picture

Status: Active » Fixed

You may use the following code in you node template:

  <?php print $node->content['rate_up_down']; ?>

Replace "up_down" by the widget name. Alternatively, you may use the following code to print all rate available widgets:

  <?php
  foreach ($node->content as $element_name => $element) {
    if (preg_match('/^rate_/', $element_name)) {
      print $element['#content'];
    }
  }
  ?>

I'm working on ways to make the rate module more easy to use. I.e., to enable adminstrators to choose a position for the widget in the admin (like fivestar does). Some sample theming will also be included in the future.

Status: Fixed » Closed (fixed)

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

seventyfive’s picture

Version: 6.x-1.0-alpha1 » 6.x-1.0-beta1
Status: Closed (fixed) » Active

I love the module and was able to implement and theme it perfectly. This saved me hours over my previous attempt to them 5star. Thank you so much for building.

Unfortunately, I'm unable to use print $node->content['rate_up_down']; in my node.tpl.php to call the widget. My widget's name is left_right so I tried using the command print $node->content['rate_left_right']; but nothing shows up. I currently have the Rate Node Display option set to "do not add automatically".

I know the widget itself is working because I have the results outputting to a debug box; however, i can't make the actual widget show up. Do I need to preprocess something? I'm kinda stuck.

Oh, in order to clarify, I'm adding it to the node.tpl.php section so that I can keep it from showing up on the teaser by using if($teaser). If you know another way to keep it from showing up on the teaser I'm open to any ideas. ;)

Thank you

mauritsl’s picture

Ah that part is indeed missing in the readme... Will add it soon.

When you choose not to add it automatically, the widget is:

$node->rate_up_down['#value'];

And when added automatically:

$node->content['rate_up_down']['#value'];

An option to decide if the widget is showing op at the teaser will be added in the future.

Note that you can see the widgets on node/123/devel/render if you have the devel module installed.

seventyfive’s picture

Status: Active » Closed (works as designed)

THANK YOU THANK YOU THANK YOU THANK YOU.

I used the first option and just renamed rate_up_down to rate_left_right where "left_right" is my widget name. Works perfectly!

Thank you for your fast response and this great module.

fadgadget’s picture

Hello mauritsl. I thought Flag Module was great till i saw this. Ideal for what i have been after and even though i havent looked at it further im sure there will be a solution to that aged old problem of multi axis voting with Fivestar. Anyhow...i really am struggling to make the widget appear in nodes. No problems with Comments. Everything works out the box for me there. I am presumming its my node.tpl thats the bugger.

I have tried both examples in #6. My widget is Emotion named 'moods'. I have tried various combinations of the Display Options along with-

<?php
$node->rate_moods['#value'];
?>

it is showing in my dev render.

content (Array, 7 elements)
-body (Array, 2 elements)
-#pre_render (Array, 1 element)
-#content_extra_fields (Array, 9 elements)
-rate_moods (Array, 2 elements)
--#value (String, 831 characters )

--#weight (Integer) 50

Ive been at it for nearly two hours and just can't seem to get it to show in my nodes. A node can be viewed here-
http://onlinebanter.com/test/test-oist

I don't know how opening issues on drupal.orh works so i wont open it. I didnt want to start a new issue when all the information might be here already.

Does anyone know where i could be going wrong? Ive updated to the latest dev version and the recommended Voting API version.

thanks

fadgadget’s picture

Aye it seems it was my 'frankensteined' node tpl. It's an awful mess. Ive slowly chipped away at the original one and ive got IF and ELSE statements and other things i don;t understand all over the place :\ For the record i deleted a load of fields and just added

<?php print $content ?>

in my node tpl. It's gonna cause me probs elsewhere but its all a learning process. Hopefully i wont have to return to this thread.

fadgadget’s picture

spoke too soon. The way my node.tpl is set up means i can't use the print content code. (due to the image in the sidebar) All i have in my node template now is-

<?php if ($node->type == 'ddblock_news_item') { ?>
<?php
$node->rate_moods['#value'];
?>

That should make the Emotions widget appear on my ddblock_news_item content type shouldnt it?

fadgadget’s picture

Status: Closed (works as designed) » Active
mauritsl’s picture

Status: Active » Fixed

You are missing a "print" there:

Turn:

$node->rate_moods['#value'];

into:

print $node->rate_moods['#value'];
fadgadget’s picture

A brilliant mauritsl thanks :) Working perfect. I suppose it makes sense now. I'll get a hang of all this yet in my lifetime i think.

Status: Fixed » Closed (fixed)
Issue tags: -rate, -rate module, -rate widget

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