I need, well wish I can create CP fieldtype for editors to add their own ratings instead of using FE form with Solspace Rating module.
Any ideas how this could be done so it would not be that hard to use and as said, only from CP when creating new channel entry.
I need at least 3 levels, so like this: Overall: 3/5 Skill level: 4/5 Foo: 1/5 Bar: 2/5
and such that editor fill in when writing an article. And then those ratings are shown in specific area with stars on FE.
Im on 2.10.1 still so that in mind, would like to know how or has anyone done this type and if so, with what fieldtype etc.
Thanks
Ok, seems that this one is an ease with GRID, even tho my code looks awful. I tested this with following: GRID field, one row that has 5 select dropdown fields. All fields has options from 1 to 5.
And then to the actual article page I did this:
{my_grid_field}
{if my_grid_field:one == 1}<i class="fa fa-star"></i>
{/if}
{if my_grid_field:two == 2}<i class="fa fa-star"></i><i class="fa fa-star"></i>
{/if}
{if my_grid_field:three == 3}<i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i>
{/if}
{if my_grid_field:four == 4}<i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i>
{/if}
{if my_grid_field:five == 5}<i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i>
{/if}
{/my_grid_field}
And that seems to work like a charm. Is there any way possible to do this with less code, or better?
You could use one select field for each thing you need to rate. In the select field just add your numbers (ie 1,2,3,4,5) for editors to choose from.
Then in your template, assuming your field is called “rating”, it’s similar you your current code…
{rating}
{if rating == "1"}<i class="fa fa-star"></i>{/if}
{if rating == "2"}<i class="fa fa-star"><i class="fa fa-star"></i>{/if}
{if rating == "3"}<i class="fa fa-star"><i class="fa fa-star"><i class="fa fa-star"></i>{/if}
{if rating == "4"}<i class="fa fa-star"><i class="fa fa-star"><i class="fa fa-star"><i class="fa fa-star"></i>{/if}
{if rating == "5"}<i class="fa fa-star"><i class="fa fa-star"><i class="fa fa-star"><i class="fa fa-star"><i class="fa fa-star"></i>{/if}
{/rating}
There is multiple fields, so I need that one Im using. Like: Overall (1-5), (Skill level needed (1-5) and such. So therefore one select field is not enough because we are pulling more data out as “team conclusion” 😊
Edit: and I already did all, by also adding 0 for to choose if article itself doesnt need that part of info, and then added another grid field for something else. Looking good and took under an hour to setup all - hope just my new team understand eventually but I know they will, if not, I’ll teach 😊
You can use as many separate select fields as you need using my method, one for each thing you want to rate. The advantage with this method is that it’s super easy just to use one particular rating type, or all of them. Sometimes has it’s uses, eg if you just want to display say the “overall” rating for any entry.
Your approach using a Grid field is sound enough though, there’s always more than one way to do things in EE 😊
yeah, indeed. I added value 0 for each dropdowns so that if content editor ignores that part, it wont appear to FE because its the default value and i’ve set conditionals to show na-da for value 0. Noticed this by myself yesterday when I added some content and woah, one set of values where shown LOL. but lucky to have an if statement available to use with default values :p
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.