Posted By

humanoid on 07/23/09


Tagged

drupal Fivestar fivestarcustomwidget


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

panatlantica


Drupal FiveStar custom widget


 / Published in: PHP
 

URL: http://drupal.org/node/313968

Drupal FiveStar change any of the settings as necessary to create a completely customized widget, regardless of the node type settings.

  1. <?php
  2. $votes = fivestar_get_votes($content_type, $content_id, $tag);
  3. $node_type = $node->type;
  4.  
  5. $values = array(
  6. 'user' => empty($votes['user']['value']) ? 0 : $votes['user']['value'],
  7. 'average' => (int)$value,
  8. 'count' => empty($votes['count']['value']) ? 0 : $votes['count']['value'],
  9. );
  10.  
  11. $settings = array(
  12. 'stars' => variable_get('fivestar_stars_'. $node_type, 5),
  13. 'allow_clear' => variable_get('fivestar_unvote_'. $node_type, FALSE),
  14. // If the user has setup this content type to use smart stars, display
  15. // the smart version instead of just the average.
  16. 'style' => variable_get('fivestar_style_'. $node_type, 'average') != 'smart' ? 'average' : 'smart',
  17. 'text' => $summary ? variable_get('fivestar_text_'. $node_type, 'dual') : 'none',
  18. 'content_type' => 'node',
  19. 'content_id' => $node->nid,
  20. 'tag' => $tag,
  21. 'autosubmit' => TRUE,
  22. 'title' => FALSE,
  23. 'feedback_enable' => $summary ? variable_get('fivestar_feedback_'. $node_type, 1) : FALSE,
  24. 'labels_enable' => $summary ? variable_get('fivestar_labels_enable_'. $node_type, 1) : FALSE,
  25. 'labels' => $summary ? variable_get('fivestar_labels_'. $node_type, array()) : array(),
  26. );
  27.  
  28. print drupal_get_form('fivestar_custom_widget', $values, $settings);
  29. ?>

Report this snippet  

You need to login to post a comment.