I want to overwrite the $link['text']
value in theme('rate_button', $link['text'], $link['href'], 'rate-btn')
, a theme function defined from the Rate module, under a specific content type in template.php. Is there a way to get that? How can I do that?
function rate_preprocess_rate_widget(&$variables) {
extract($variables);
$buttons = array();
foreach ($links as $link) {
$button = theme('rate_button', $link['text'], $link['href'], 'rate-btn');
$buttons[] = $button;
}
$variables['buttons'] = $buttons;
$info = array();
if ($mode == RATE_CLOSED) {
$info[] = t('Voting is closed.');
}
if ($mode != RATE_COMPACT && $mode != RATE_COMPACT_DISABLED) {
if ($results['user_vote']) {
$info[] = t('You voted \'@option\'.', array('@option' => t($results['user_vote'])));
}
}
$variables['info'] = implode(' ', $info);
}
This is the code of theme_rate_button()
.
function theme_rate_button($text, $href, $class = NULL) {
static $id = 0;
$id++;
$classes = 'rate-button';
if ($class) {
$classes .= ' ' . $class;
}
if (empty($href)) {
// Widget is disabled or closed.
return
'<span class="' . $classes . '" id="rate-button-' . $id . '">' .
check_plain($text) .
'</span>';
}
else {
return
'<a class="' . $classes . '" id="rate-button-' . $id . '" rel="nofollow" href="' . htmlentities($href) . '">' .
check_plain($text) .
'</a>';
}
}
The reason I am asking is that I have installed the rate module, and created the emotion vote (only one), which is used in two content types ("story", and "company"). In the "story" content type, the vote button should show two buttons labelled "best" and "bad," but in the "company" content type I want to set the buttons to "up" and "down."
The local variable $links
used in rate_preprocess_rate_widget()
contain the data for two buttons, of which I want to change the label basing on the content type of the node where those buttons appear.