Screenshot of the result on front end by default with the core theme Bartik
Screenshot of the source code showing available Twig template for theming.
Screenshot of the configuration form for the Flag module.

This module is an extension of the great Flag module.

Only supports Drupal 8.

How to install

composer require  drupal/flag_rating
drush en flag_rating

How to configure

  • Create a new Flag under Admin > Structure > Flag
  • Select the plugin type: AJAX Rating Link
  • Save the Flag and edit it again
  • Select the field which will holds the scores
  • Optional: Upload an icon
  • Save your changes

Now, place the Flag on your content as you would usually do with fields - under Admin > Structure > Content Type > Article > Manage Display.

How to customize output (icon + Twig + CSS)

A default SVG icon star.svg is provided by default but you can upload a different icon (png, jpg, jpeg or svg) for each different Flag.

Also, there are two useful templates that you can even override with some suggestions:

  • flag-rating.html.twig
  • flag-rating-icon.html.twig

Finally, you can override or extend the CSS in your theme .info file like this:

...
libraries-extend:
  flag_rating/flag.rating: 
    - yourtheme/yourlibraryname
...

Questions? Bugs? Please read the issue queue and feel free to open a bug if needed.

Project information

Releases