我在 Drupal 6 中使用 Fivestar 模块... http://drupal.org/project/fivestar
而且,我想更改文本:
从: Average: *****
对此: Rate this Article: *****
我宁愿不破解使用字符串覆盖的模块,我希望在 template.php 文件中使用 hook_form_alter 函数或类似的东西。
这是 HTML 的样子:
<form action="/fall-foliage" accept-charset="UTF-8" method="post" id="fivestar-form-node-232" class="fivestar-widget"><div>
<div class="fivestar-form-vote-232 clear-block"><input type="hidden" name="content_type" id="edit-content-type" value="node" />
<input type="hidden" name="content_id" id="edit-content-id" value="232" /><div class="fivestar-form-item fivestar-average-stars fivestar-labels-hover">
<div class="form-item" id="edit-vote-wrapper">
<label for="edit-vote">Average: </label>
...etc...
Fivestar.module 中的代码如下所示:
function theme_fivestar_summary($user_rating, $average_rating, $votes, $stars = 5, $feedback = TRUE) {
$output = '';
$div_class = '';
if (isset($user_rating)) {
$div_class = isset($votes) ? 'user-count' : 'user';
$user_stars = round(($user_rating * $stars) / 100, 1);
$output .= '<span class="user-rating">'. t('Your rating: <span>!stars</span>', array('!stars' => $user_rating ? $user_stars : t('None'))) .'</span>';
}
if (isset($user_rating) && isset($average_rating)) {
$output .= ' ';
}
if (isset($average_rating)) {
$div_class = isset($votes) ? 'average-count' : 'average';
$average_stars = round(($average_rating * $stars) / 100, 1);
$output .= '<span class="average-rating">'. t('Average: <span>!stars</span>', array('!stars' => $average_stars)) .'</span>';
}