You are here

function hook_rate_templates in Rate 8.2

Same name and namespace in other branches
  1. 6.2 rate.hooks.inc \hook_rate_templates()
  2. 7 rate.hooks.inc \hook_rate_templates()

Define templates for rate widgets.

Return value

array Array of template objects, keyed by the template name.

1 function implements hook_rate_templates()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

rate_rate_templates in ./rate.module
Implements hook_rate_templates().
1 invocation of hook_rate_templates()
RateWidgetForm::form in src/RateWidgetForm.php
Gets the actual form array to be built.

File

./rate.api.php, line 83
Provides hook documentation for the Rate module.

Code

function hook_rate_templates() {
  $templates = [];
  $templates['thumbs_up_down'] = new stdClass();
  $templates['thumbs_up_down']->value_type = 'points';
  $templates['thumbs_up_down']->options = [
    [
      'value' => 1,
      'label' => 'up',
      'class' => 'rate-updown-up',
    ],
    [
      'value' => -1,
      'label' => 'down',
      'class' => 'rate-updown-down',
    ],
  ];
  $templates['thumbs_up_down']->customizable = FALSE;
  $templates['thumbs_up_down']->translate = TRUE;
  $templates['thumbs_up_down']->template_title = t('Thumbs up / down');
  $templates['fivestar'] = new stdClass();
  $templates['fivestar']->value_type = 'percent';
  $templates['fivestar']->options = [
    [
      'value' => 0,
      'label' => '1',
    ],
    [
      'value' => 25,
      'label' => '2',
    ],
    [
      'value' => 50,
      'label' => '3',
    ],
    [
      'value' => 75,
      'label' => '4',
    ],
    [
      'value' => 100,
      'label' => '5',
    ],
  ];
  $templates['fivestar']->customizable = FALSE;
  $templates['fivestar']->translate = FALSE;
  $templates['fivestar']->template_title = t('Fivestar');
  return $templates;
}