Project
Star Rating
Initial solution to display the star rating is based on a w3schools.com How To:
- in the Review node, create field_review_rating of type Integer and add the star options
- the custom HTML markup for this field is provided by
theme_preprocess_field()
in template.php - create/add field--field-review-rating.tpl.php to the theme's template folder and use the custom HTML markup to override its display
- Font Awesome Icon Library is loaded in html.tpl.php
- add the CSS to color the stars in the theme's CSS folder
This works fine when a node is displayed. But what about a list of reviews produced by Views?
How can I reproduce the node's custom display in a Views' display? It's definitely possible but it quickly gets more complicated. It also means that our system will have 2 templates to handle these 2 separate contexts, duplication is rarely ideal and often leads to more work and errors...
AH! a better solution would be to use a content view mode e.g. Teaser instead of fields, that way there is no need to work with Views' templates + the work done in field--field-review-rating.tpl.php 100% recyclable :)