Need Help Implementing Reviews

Hello,

I am attempting to use the Reviews extra to allow for users to be rated, and for those ratings to be associated with particular user accounts, but the documentation appears to only show instructions for displaying existing ratings, and these ratings seem to be bound to resources rather than users, unless I am misunderstanding and users are also resources that can be referenced. If anyone has experience with this extra, could you please provide me with an example of how to use it to display a rating form field, and also how to display existing ratings?

If this extra is not ideal for this use case, recommendations for alternatives would also be very greatly appreciated.

Thanks!

I never used the extra Reviews, but I took a quick look at the code and you’re correct: It’s to rate resources and not users.

Also, the (current) version 1.2.0-pl doesn’t seem to have the built-in functionality to add ratings from the frontend.


There only exists this fork of the repository where a form and a FormIt hook was added:

But I don’t think these changes where ever published as an installable transport package.


If you have some programming experience, you could probably take this code as the basis for a custom solution (that replaces modResource with modUser).

Or you could create your own custom solution from scratch using MIGXdb to create the custom database tables and manager page.

Thank you very much for the quick response and for confirming my suspicions. I am going to try to see what I can do with this extra. Do you know how to go about adding ratings through the back end? It looks like the extra added three tables to my modx database: modx_reviews_rating, modx_reviews_review, and modx_reviews_review_rating. I tried adding a row to each of these tables, referencing the same ID in all of the tables, and when I call [[!reviews]] in my chunk, the name of the review and its associated comment are displayed, but no star rating is displayed. I see a list going from “5 stars” to “1 star”, but the value for each star is blank. The only column that appears to resemble a star rating is the value column of modx_reviews_review_rating, but the value that I put into this column does not appear to be rendering as a star rating. Do you know if this is the correct column to add star ratings through?

There exists the functionality to add reviews from the manager (In the menu “Extras” → “Reviews”).

First change to the “Admin view” (in the upper right corner) and create some “Ratings” (like price, quality, etc.)
Then back in the “Default view”, you can create “Reviews” (and select a value for every “Rating” in the vertical tab “Rating”).
(The system setting reviews.resource_aware has to be changed to Yes to be able to assign the review to a resource.)


It seems to me that the code was changed (to allow for different “Ratings” like price, quality, etc.) but the default template chunks where never updated to account for this.

The see the actual ratings, you have to supply your own template chunks:

[[!reviews?
    &tpl=`reviewTpl`
    &tplWrapper=`reviewWrapper`
]]

Chunk “reviewTpl”

Instead of the placeholder [[+rating]] in the default chunk, add something like this to your custom chunk:

<ul>
    <li>average: [[+average]]</li>
    <li>[[+ratingTypes.1.name]]: [[+ratings.1]]</li>
    <li>[[+ratingTypes.2.name]]: [[+ratings.2]] </li>
</ul>

Chunk “reviewWrapper”

Instead of [[+stats.5]] ... in the default chunk, use something like this in your custom chunk:

<ul>
	<li>[[+ratingStats.1.name]]: [[+ratingStats.1.value]]</li>
	<li>[[+ratingStats.2.name]]: [[+ratingStats.2.value]]</li>
</ul>