You are here

README.txt in Rate 6.2

Same filename and directory in other branches
  1. 8.2 README.txt
  2. 8 README.txt
  3. 7 README.txt
PREFACE
-------
This module provides flexible voting widgets for nodes and comments.
Administrators can add multiple widgets and define an unlimited number of
buttons.

CONTENTS
--------
1. Installation
2. Configuration
2.1. Widget configuration
3. Widget types
4. Theming
5. Voting results
6. Views integration
7. Expiration (close voting on a specified date)
8. Using rate in blocks or panels
9. Hooks

1. Installation
--------------------------------------------------------------------------------
Before installing Rate, you need VotingAPI. If not already installed, download
the latest stable version at http://drupal.org/project/votingapi
Please follow the readme file provided by VotingAPI on how to install.

Copy Rate into your modules directory (i.e. sites/all/modules) and enable Rate
(on admin/build/modules).

Optional modules:

* Chart
  To view the charts in the vote results tab, you also need to install the "chart"
  module, which you can get at http://drupal.org/project/chart.
* Date
  The date module is a requirement for the Rate Expiration module.

2. Configuration
--------------------------------------------------------------------------------
After installation, the configuration page will be available at
admin/build/rate. This page shows a list with available widgets. Each widget
have an edit and delete link. You can add a tab on the form below 'Add widget'.
In this form you have to choose a widget type. See section 3 for more
information on this topic. Both editing and adding a widget leads to the widget
configuration (see §2.1).

If you want users other than admin to access the voting results page, you need
to give them the "view rate results page" permission on admin/user/permissions.

2.1. Widget configuration
-------------------------
The elements on the widget configuration form are explained in this paragraph.
Note that some elements may not be available depending on the widget type you
use, these are "Value type", "Options" and "Translate options".

* Title
  The title is only used in the admin section. Use a recognizable name.
* Machine readable name
  Name used for technical purposes. You may only contain alphanumeric characters
  and underscores.
* Tag
  This is the tag used by VotingAPI to store the voting results. Voting results
  from different tags are never merged. You can use this to allow multiple
  ratings on the same node (i.e. for "comfort", "location", "services" etc.).
  The default tag for ratings is "vote". Use this value if you do not allow
  ratings on specific aspects.
* Value type
  This determines how vote results are totaled. VotingAPI supports three value
  types by default: 'Percentage' votes are averaged, 'Points' votes are summed
  up, and 'Options' votes get a count of votes cast for each specific option.
  Typical usages are:
  * Thumbs up / down: use points
  * Bad / mediocre / good: use percentage
  * Makes me funny / boring / mad / angry: use options
* Options
  These are the options displayed to the user. Each option has a value and a
  label. See §2.2 for more information on how to configure options.
* Translate options
  This checkbox determines if the labels used for the options should be
  translated.
* Node types
  Check the node types on which a rate widget should be available. There are
  separate columns for nodes and comments in this table.
* Node display
  Determines where the widget will be placed. There are three options:
  * Do not add automatically: The widget is added in the node object, but not
    within the content array. This only makes sense if you place the widget
    somewere by hand in the node theming.
  * Above the content: The content will be prepended by the widget.
  * Below the content: Selected by default. The widget is appended to the
    content.
* Display in teaser
  Check this box if you want the widget to be visible in the node teaser.
* Comment display
  Same as node display, but for comments.
* Roles
  Check the roles which are allowed to vote using this widget. All roles are
  allowed to vote if no roles are checked.
* Behaviour when user has no permissions to vote
  If the user may not vote on the widget, what needs to be done? Options are:
  * Redirect to login and show message.
    The widget is visible just as if you may vote on in. If the user clicks on
    a button, the user is redirected to the user page which shows the message
    'You must login before you can vote.'. The user is redirected back to the
    page with the rate widget after login.
  * Redirect to login but do not show a message.
    This behaviour is the same as the first option, except for the fact that it
    does not display a message.
  * Show a disabled widget (with non clickable buttons).
    The user is able to see the widget, but cannot click on it.
  * Hide widget
    The widget is not visible to the user if he does not have the permission to
    vote.

2.2. Options
------------
Options are the "buttons" dispayed in the widget. These can be visually
different, depending on the theming. Options are generated as HTML links by
default.

Each option has a value and a label. Only the label is visible for the user, but
the value is what he actually votes for when clicking the button.

Values have to be configured according to the following rules:
* Values must be integers (may be negative). thus '1', '2', '0', '-3' are all
  right, but '2.3' is wrong.
* Values must be unique across all options within the same widget.

Which value you should use depends on the value type setting. When using points,
these are the points which will be added when clicking that button. So "thumbs
up" must have the value '1', "thumbs down" the value '-1' and "neutral" '0'. For
'Percentage' you have to use whole numbers between 0 and 100. When using
'Options', you may use any number as long as they are unique. It doesn't have to
make sense as they are only used for storage.

3. Widget types
--------------------------------------------------------------------------------
Technically, widget types are sets of "value types" and "options" (see §2.1).
They are called 'templates' in code.

Some widget types have the option to let the user customize the options, others
don't allow the user to do that. But all widget types have a predefined set of
options.

You may create widgets without choosing a "template" by selecting the 'Custom'
type. By using 'Custom', you have to add the theming for this widget (see
section 4).

Widget types can be extended by 3rd party modules. The following widget types
are provided by the rate module:

* Thumbs up
* Thumbs up / down
* Fivestar
* Emotion
* Was this helpful?

4. Theming
--------------------------------------------------------------------------------
Default templates for theming are:

* rate-widget.tpl.php
  This is the default template for all custom widgets.
* rate-widget--NAME.tpl.php
  This is a widget specific template. Use the machine name for NAME. Replace
  underscores by dashes in this name. This template is only available for custom
  widgets.

Theming for non-custom widget types are defined in the module which provides
the widget type.

You may use the following snippets in the template:

* Print a button for a single option:

    <?php print $links[0]['content']; ?>

  '0' is the first option (see §2.1). For a thumbs up / down
  configuration you will have:

    <?php print $links[0]['content']; ?>
    <?php print $links[1]['content']; ?>

* Print the rating when using value type 'percentage' or 'points':

    <?php print $results['rating']; ?>

* Print the number of votes for a specific option (only available when using
  value type 'options'):

    <?php print $links[0]['votes']; ?>

  '0' is the first option (see §2.1).

* Print the total number of votes:

  <?php print $results['count']; ?>

* For thumbs up / down widgets, there are 2 special variables available which
  provides the percentage of votes for up and down.

  <?php print $results['up_percentage']; ?>
  <?php print $results['down_percentage']; ?>

You can choose to not automatically add the widget to the node template. In that
case, the widget can be used as:

<?php print $node->rate_NAME['#value']; ?>

Replace NAME by the widget's machine readable name.

5. Voting results
--------------------------------------------------------------------------------
Voting results are available on the voting results page. You can get there by
clicking the "Voting results" tab on the node page. Note that this tab is hidden
if the node does not have any rate widgets or if you do not have the
"view rate results" permission.

When the chart module is enabled, you will find charts of the results in the
last 30 days on this page. The chart may show less than 30 days if there was no
activity on all days.

The voting results page is only available for nodes.

6. Views integration
--------------------------------------------------------------------------------
This module provides views integration via the VotingAPI module. To add a rate
widget in your view, first add a relation to "Node: Vote results". You have to
configure a few options here. The "Value type" and "Vote tag" needs to be the
same as used for the widget (see §2.1). The "aggregate" function must be
"Number of votes".

After adding the relationship, you can add the field "Vote results: Value" to
your view. In the "Appearance" box you may choose one of the following:

* Rate widget (display only)
  This shows a disabled widget. Uses are allowed to see the results, but cannot
  click the buttons.
* Rate widget (compact)
  This shows a compact widget. This is the basic widget without the textual
  information.
* Rate widget
  This shows the full widget (as on the node page).

You are advised to add the "Node: Type" field to your view fields. If you do
not, an additional query will be executed per row. You may exclude this field
from display.

Views integration for comments is not supported at the moment.

7. Expiration (close voting on a specified date)
--------------------------------------------------------------------------------
The optional Rate Expiration module allows you to close voting on a specified
date. When adding or editing a rate widget, you will find the following options:

* Disable voting after this period
  When set, voting is closed when the configured period has ellapsed since node
  creation. Users are not able to click the buttons when voting is closed.
* Allow override
  When checked, the start- en enddates for voting can be set in the node edit
  form.

8. Using rate in blocks or panels
--------------------------------------------------------------------------------
You can place the rate widget on a node page in a block or (mini) panel. Add
a custom block with the PHP code input filter or a panel with PHP code and use
the following code:

<?php
if (arg(0) == 'node' && is_numeric(arg(1)) && $node = node_load(arg(1))) {
  node_invoke_nodeapi($node, 'view');
  print $node->rate_NAME['#value'];
}
?>

Replace NAME by the widget's machine readable name.

The display setting for nodes must be set to "Do not add automatically".

9. Hooks
--------------------------------------------------------------------------------
There are two Javascript hooks available; eventBeforeRate and eventAfterRate.
This hook has an argument 'data'. This is an object which contains the variables
'content_type', 'content_id', 'widget_id' and 'widget_mode'. Example of use:

$(document).bind('eventAfterRate', function(event, data)
{
  alert('eventAfterRate called');
});

File

README.txt
View source
  1. PREFACE
  2. -------
  3. This module provides flexible voting widgets for nodes and comments.
  4. Administrators can add multiple widgets and define an unlimited number of
  5. buttons.
  6. CONTENTS
  7. --------
  8. 1. Installation
  9. 2. Configuration
  10. 2.1. Widget configuration
  11. 3. Widget types
  12. 4. Theming
  13. 5. Voting results
  14. 6. Views integration
  15. 7. Expiration (close voting on a specified date)
  16. 8. Using rate in blocks or panels
  17. 9. Hooks
  18. 1. Installation
  19. --------------------------------------------------------------------------------
  20. Before installing Rate, you need VotingAPI. If not already installed, download
  21. the latest stable version at http://drupal.org/project/votingapi
  22. Please follow the readme file provided by VotingAPI on how to install.
  23. Copy Rate into your modules directory (i.e. sites/all/modules) and enable Rate
  24. (on admin/build/modules).
  25. Optional modules:
  26. * Chart
  27. To view the charts in the vote results tab, you also need to install the "chart"
  28. module, which you can get at http://drupal.org/project/chart.
  29. * Date
  30. The date module is a requirement for the Rate Expiration module.
  31. 2. Configuration
  32. --------------------------------------------------------------------------------
  33. After installation, the configuration page will be available at
  34. admin/build/rate. This page shows a list with available widgets. Each widget
  35. have an edit and delete link. You can add a tab on the form below 'Add widget'.
  36. In this form you have to choose a widget type. See section 3 for more
  37. information on this topic. Both editing and adding a widget leads to the widget
  38. configuration (see §2.1).
  39. If you want users other than admin to access the voting results page, you need
  40. to give them the "view rate results page" permission on admin/user/permissions.
  41. 2.1. Widget configuration
  42. -------------------------
  43. The elements on the widget configuration form are explained in this paragraph.
  44. Note that some elements may not be available depending on the widget type you
  45. use, these are "Value type", "Options" and "Translate options".
  46. * Title
  47. The title is only used in the admin section. Use a recognizable name.
  48. * Machine readable name
  49. Name used for technical purposes. You may only contain alphanumeric characters
  50. and underscores.
  51. * Tag
  52. This is the tag used by VotingAPI to store the voting results. Voting results
  53. from different tags are never merged. You can use this to allow multiple
  54. ratings on the same node (i.e. for "comfort", "location", "services" etc.).
  55. The default tag for ratings is "vote". Use this value if you do not allow
  56. ratings on specific aspects.
  57. * Value type
  58. This determines how vote results are totaled. VotingAPI supports three value
  59. types by default: 'Percentage' votes are averaged, 'Points' votes are summed
  60. up, and 'Options' votes get a count of votes cast for each specific option.
  61. Typical usages are:
  62. * Thumbs up / down: use points
  63. * Bad / mediocre / good: use percentage
  64. * Makes me funny / boring / mad / angry: use options
  65. * Options
  66. These are the options displayed to the user. Each option has a value and a
  67. label. See §2.2 for more information on how to configure options.
  68. * Translate options
  69. This checkbox determines if the labels used for the options should be
  70. translated.
  71. * Node types
  72. Check the node types on which a rate widget should be available. There are
  73. separate columns for nodes and comments in this table.
  74. * Node display
  75. Determines where the widget will be placed. There are three options:
  76. * Do not add automatically: The widget is added in the node object, but not
  77. within the content array. This only makes sense if you place the widget
  78. somewere by hand in the node theming.
  79. * Above the content: The content will be prepended by the widget.
  80. * Below the content: Selected by default. The widget is appended to the
  81. content.
  82. * Display in teaser
  83. Check this box if you want the widget to be visible in the node teaser.
  84. * Comment display
  85. Same as node display, but for comments.
  86. * Roles
  87. Check the roles which are allowed to vote using this widget. All roles are
  88. allowed to vote if no roles are checked.
  89. * Behaviour when user has no permissions to vote
  90. If the user may not vote on the widget, what needs to be done? Options are:
  91. * Redirect to login and show message.
  92. The widget is visible just as if you may vote on in. If the user clicks on
  93. a button, the user is redirected to the user page which shows the message
  94. 'You must login before you can vote.'. The user is redirected back to the
  95. page with the rate widget after login.
  96. * Redirect to login but do not show a message.
  97. This behaviour is the same as the first option, except for the fact that it
  98. does not display a message.
  99. * Show a disabled widget (with non clickable buttons).
  100. The user is able to see the widget, but cannot click on it.
  101. * Hide widget
  102. The widget is not visible to the user if he does not have the permission to
  103. vote.
  104. 2.2. Options
  105. ------------
  106. Options are the "buttons" dispayed in the widget. These can be visually
  107. different, depending on the theming. Options are generated as HTML links by
  108. default.
  109. Each option has a value and a label. Only the label is visible for the user, but
  110. the value is what he actually votes for when clicking the button.
  111. Values have to be configured according to the following rules:
  112. * Values must be integers (may be negative). thus '1', '2', '0', '-3' are all
  113. right, but '2.3' is wrong.
  114. * Values must be unique across all options within the same widget.
  115. Which value you should use depends on the value type setting. When using points,
  116. these are the points which will be added when clicking that button. So "thumbs
  117. up" must have the value '1', "thumbs down" the value '-1' and "neutral" '0'. For
  118. 'Percentage' you have to use whole numbers between 0 and 100. When using
  119. 'Options', you may use any number as long as they are unique. It doesn't have to
  120. make sense as they are only used for storage.
  121. 3. Widget types
  122. --------------------------------------------------------------------------------
  123. Technically, widget types are sets of "value types" and "options" (see §2.1).
  124. They are called 'templates' in code.
  125. Some widget types have the option to let the user customize the options, others
  126. don't allow the user to do that. But all widget types have a predefined set of
  127. options.
  128. You may create widgets without choosing a "template" by selecting the 'Custom'
  129. type. By using 'Custom', you have to add the theming for this widget (see
  130. section 4).
  131. Widget types can be extended by 3rd party modules. The following widget types
  132. are provided by the rate module:
  133. * Thumbs up
  134. * Thumbs up / down
  135. * Fivestar
  136. * Emotion
  137. * Was this helpful?
  138. 4. Theming
  139. --------------------------------------------------------------------------------
  140. Default templates for theming are:
  141. * rate-widget.tpl.php
  142. This is the default template for all custom widgets.
  143. * rate-widget--NAME.tpl.php
  144. This is a widget specific template. Use the machine name for NAME. Replace
  145. underscores by dashes in this name. This template is only available for custom
  146. widgets.
  147. Theming for non-custom widget types are defined in the module which provides
  148. the widget type.
  149. You may use the following snippets in the template:
  150. * Print a button for a single option:
  151. '0' is the first option (see §2.1). For a thumbs up / down
  152. configuration you will have:
  153. * Print the rating when using value type 'percentage' or 'points':
  154. * Print the number of votes for a specific option (only available when using
  155. value type 'options'):
  156. '0' is the first option (see §2.1).
  157. * Print the total number of votes:
  158. * For thumbs up / down widgets, there are 2 special variables available which
  159. provides the percentage of votes for up and down.
  160. You can choose to not automatically add the widget to the node template. In that
  161. case, the widget can be used as:
  162. rate_NAME['#value']; ?>
  163. Replace NAME by the widget's machine readable name.
  164. 5. Voting results
  165. --------------------------------------------------------------------------------
  166. Voting results are available on the voting results page. You can get there by
  167. clicking the "Voting results" tab on the node page. Note that this tab is hidden
  168. if the node does not have any rate widgets or if you do not have the
  169. "view rate results" permission.
  170. When the chart module is enabled, you will find charts of the results in the
  171. last 30 days on this page. The chart may show less than 30 days if there was no
  172. activity on all days.
  173. The voting results page is only available for nodes.
  174. 6. Views integration
  175. --------------------------------------------------------------------------------
  176. This module provides views integration via the VotingAPI module. To add a rate
  177. widget in your view, first add a relation to "Node: Vote results". You have to
  178. configure a few options here. The "Value type" and "Vote tag" needs to be the
  179. same as used for the widget (see §2.1). The "aggregate" function must be
  180. "Number of votes".
  181. After adding the relationship, you can add the field "Vote results: Value" to
  182. your view. In the "Appearance" box you may choose one of the following:
  183. * Rate widget (display only)
  184. This shows a disabled widget. Uses are allowed to see the results, but cannot
  185. click the buttons.
  186. * Rate widget (compact)
  187. This shows a compact widget. This is the basic widget without the textual
  188. information.
  189. * Rate widget
  190. This shows the full widget (as on the node page).
  191. You are advised to add the "Node: Type" field to your view fields. If you do
  192. not, an additional query will be executed per row. You may exclude this field
  193. from display.
  194. Views integration for comments is not supported at the moment.
  195. 7. Expiration (close voting on a specified date)
  196. --------------------------------------------------------------------------------
  197. The optional Rate Expiration module allows you to close voting on a specified
  198. date. When adding or editing a rate widget, you will find the following options:
  199. * Disable voting after this period
  200. When set, voting is closed when the configured period has ellapsed since node
  201. creation. Users are not able to click the buttons when voting is closed.
  202. * Allow override
  203. When checked, the start- en enddates for voting can be set in the node edit
  204. form.
  205. 8. Using rate in blocks or panels
  206. --------------------------------------------------------------------------------
  207. You can place the rate widget on a node page in a block or (mini) panel. Add
  208. a custom block with the PHP code input filter or a panel with PHP code and use
  209. the following code:
  210. if (arg(0) == 'node' && is_numeric(arg(1)) && $node = node_load(arg(1))) {
  211. node_invoke_nodeapi($node, 'view');
  212. print $node->rate_NAME['#value'];
  213. }
  214. ?>
  215. Replace NAME by the widget's machine readable name.
  216. The display setting for nodes must be set to "Do not add automatically".
  217. 9. Hooks
  218. --------------------------------------------------------------------------------
  219. There are two Javascript hooks available; eventBeforeRate and eventAfterRate.
  220. This hook has an argument 'data'. This is an object which contains the variables
  221. 'content_type', 'content_id', 'widget_id' and 'widget_mode'. Example of use:
  222. $(document).bind('eventAfterRate', function(event, data)
  223. {
  224. alert('eventAfterRate called');
  225. });