theme_nodeapi_example_rating

Versions
4.6 – 7
theme_nodeapi_example_rating($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.

Code

developer/examples/nodeapi_example.module, line 147

<?php
function theme_nodeapi_example_rating($rating) {
  $output = '<div class="nodeapi_example_rating">';
  $options = array(
    0 => t('Unrated'),
    1 => t('Poor'),
    2 => t('Needs improvement'),
    3 => t('Acceptable'),
    4 => t('Good'),
    5 => t('Excellent'));
  $output .= t('Rating: %rating', array('%rating' => $options[(int)$rating]));
  $output .= '</div>';
  return $output;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.