1 node_hooks_example.module theme_node_hooks_example_rating($variables)

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


modules/examples/node_hooks_example/node_hooks_example.module, line 255
Hook implementations for the Node Hooks Example module.


function theme_node_hooks_example_rating($variables) {
  $options = array(
    0 => t('Unrated'),
    1 => t('Poor'),
    2 => t('Needs improvement'),
    3 => t('Acceptable'),
    4 => t('Good'),
    5 => t('Excellent'),
  $output = '<div class="node_hooks_example_rating">';
  $output .= t('Rating: %rating', array('%rating' => $options[(int) $variables['rating']]));
  $output .= '</div>';
  return $output;