I was developing a site which used the 'seemingly now disappeared' method for calling the widgit via theme_vote_up_down($nid, 'node') where the NID and 'type' could be put straight into the function - this was the method for displaying the widgit and voting.

In Beta4 this seems to have disappeared, and been replaced by a more complex set of sub-functions.

What would be the best way to implement the functionality of this depreciated function?

Using node.tpl.php is inpractical - I'm calling NIDs straight from the database, the overhead of a custom .tpl.php file would be atrocious.

Comments

zhte’s picture

Sorry, title should be: theme_vote_up_down_widget($nid, 'node')

The code for this function was:

function theme_vote_up_down_widget($cid, $type) {
  global $user;
  drupal_add_css(drupal_get_path('module', 'vote_up_down') .'/vote_up_down.css');
  drupal_add_js(drupal_get_path('module', 'vote_up_down') .'/ajax_vote_up_down.js');
  
  if (user_access('view up/down votes')) {
    $output = '<div class="vote-up-down-widget">';
    if (user_access('use vote up/down') && ($user->uid || variable_get('vote_up_down_anonymous_vote', 0))) {
      $criteria = array('content_type' => $type, 'content_id' => $cid, 'uid' => _vote_up_down_get_uid());
      $user_vote = votingapi_select_single_vote_value($criteria);

      if ($user_vote > 0) {
        $class = 'vote-up-act';
        $class2 = 'vote-down-inact';
      }
      else if ($user_vote < 0) {
        $class = 'vote-up-inact';
        $class2 = 'vote-down-act';
      }
      else {
        $class = 'vote-up-inact';
        $class2 = 'vote-down-inact';
      }

      $output .= '<span id="vote_up_'. $cid .'" class="'. $class .'" title="'. url("vote_up_down/$type/$cid/1/1") .'">'. l('', "vote_up_down/$type/$cid/1", array('class' => $class, 'title' => t('Vote up')), drupal_get_destination(), NULL, FALSE, TRUE) .'</span>';
      $output .= '<span id="vote_down_'. $cid .'" class="'. $class2 .'" title="'. url("vote_up_down/$type/$cid/-1/1") .'">'. l('', "vote_up_down/$type/$cid/-1", array('class' => $class2, 'title' => t('Vote down')), drupal_get_destination(), NULL, FALSE, TRUE) .'</span>';
    }
    else {
      $output .= '<span class="up-inact" title="'. t('You must login to vote!') .'"></span>';
      $output .= '<span class="down-inact" title="'. t('You must login to vote!') .'"></span>';
    }

    $output .= '</div>';

    return $output;
  }
}
mrwendell’s picture

Status: Active » Closed (works as designed)

They are now using preprocess variables in combination with theme files, instead of the venerable themable function.

Look in vote_up_down.module for the following functions

  • template_preprocess_vote_up_down_widget(&$variables)
  • template_preprocess_vote_up_down_widget_alt(&$variables)
  • template_preprocess_vote_up_down_points(&$variables)

You can overwrite/add variables by copying the function to your template.php file of your theme and renaming to

THEMENAME_preprocess_vote_up_down_widget
THEMENAME_preprocess_vote_up_down_widget_alt
THEMENAME_preprocess_vote_up_down_points

where THEMENAME is a place holder for your theme's name, or you could try 'phptemplate' which should also work, though I haven't tried. This can be a quick way to do things like overwrite labels (e.g. points -> diggs ) without having to overwriting the widget layout.

To do the latter, the theme files can be found in

/sites/all/modules/vote_up_down/themes

You can copy the appropriate theme file to your theme directory and modify how the widget HTML is formed.

I found this out using the devel.module (http://drupal.org/project/devel) and enabling the drupal themer info. This will give you a run down of all files and functions used to create a specific component on your site.

Happy Voting!