function theme_nodeapi_example_rating in Examples for Developers 6
Same name and namespace in other branches
- 7 nodeapi_example/nodeapi_example.module \theme_nodeapi_example_rating()
A custom theme function.
By using this function to format our rating, themes can override this presentation if they wish; for example, they could provide a star graphic for the rating. We also wrap the default presentation in a CSS class that is prefixed by the module name. This way, style sheets can modify the output without requiring theme code.
Related topics
1 theme call to theme_nodeapi_example_rating()
- nodeapi_example_nodeapi in nodeapi_example/
nodeapi_example.module - Implementation of hook_nodeapi().
File
- nodeapi_example/
nodeapi_example.module, line 177 - This is an example outlining how a module can be used to extend existing content types.
Code
function theme_nodeapi_example_rating($rating) {
$options = array(
0 => t('Unrated'),
1 => t('Poor'),
2 => t('Needs improvement'),
3 => t('Acceptable'),
4 => t('Good'),
5 => t('Excellent'),
);
$output = '<div class="nodeapi_example_rating">';
$output .= t('Rating: %rating', array(
'%rating' => $options[(int) $rating],
));
$output .= '</div>';
return $output;
}