Jump to content

[Easy] How to build site architecture for "ratings"?


Recommended Posts

Hi. I'm working on building my first processwire site, and I want to make sure I'm getting it right. I'd appreciate any feedback. 

I have a `vendor.php` template/model that will contain companies.

I need to give users the ability to rate (1-5) that vendor. So I think I need to build a `vendor_rating.php` model/template  with fields `rating` (int), `user` (ref), `vendor` (ref), and perhaps a textarea for `review`.  Then, in the vendor template I will call and cache the average vendor rating for display. I don't actually want to display the individual ratings anywhere, so I guess I still need to figure out how to do an ajax call from the front end. 


Here's the thing. This structure is almost identical to "comments" with only one extra field for the `rating`. So should I just extend that in some way? Or stick to my current path and make a new model/template?



Link to comment
Share on other sites

5 hours ago, skoskie said:

This structure is almost identical to "comments" with only one extra field for the `rating`.

Welcome to the forums @skoskie 🙂

The Comments fieldtype already includes a star rating option: https://processwire.com/blog/posts/processwire-2.6.21-upgrades-comments-more-on-pw-3.x/#new-star-ratings-for-comments-fields

  • Like 3
Link to comment
Share on other sites


here is Rating module what I developed for project but at the end didn't use it (p.s.). and if you want you can use/test it.
It use Ajax POST on front-end and cookie to prevent multiple votes . Inside module global settings you have option to set desired max number of stars for votes (up to 10). For usage and instructions please read README.md file (and do not skip step 5.).

Here are some screenshots

Field in admin backend:


Front-end (echo $page->my_rating_field)


Clean cookie (for testing)



This is not polished module version, and only what is "complex" is how to include javascript files, but there are instructions how to do that, and if that is a problem I will do some changes or feel free to contact me for free support/assistance.


I developed this module for project (2018.) where one task was and comments component, and that's was ok but my problem was that I first developed this module, and after that installed Ryan Comments module. I didn't know that Comments module has rating part 🙂 !@#$%...".



  • Like 4
  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By AndZyk
      The Architekturforum Freiburg sees itself as a regional platform for information and exchange about architecture, urban planning, landscape architecture and building culture. On the website you can register for events, view presentations or become a member.
      The website uses UIkit as framework and Workbox for the PWA.
      Dynamic primary color Structured data  
      Dynamic primary color

      The events are grouped in programs and every program can have its own color. For this I used the awesome module Color. I defined a fixed color palette, so that no ugly colors could be selected and I worked for the first time with CSS variables. With CSS variables you are more flexible than with f.e. SCSS variables and can change the primary color for the whole website on the fly. This is used on the detail page of events with a different primary color.
      Structured data
      It was important for me to provide the correct structured data for the events. Since the pandemic they have been enhanced for online, offline and mixed events.
      Modules used:
      Repeater Matrix Form Builder Functional Fields Map Marker ProCache Upgrades TOTP two-factor authentication Tracy Debugger Color Sitemap Email Obfuscation (EMO)  
      Regards, Andreas
    • By AndZyk
      This is a minimalistic website for the german architecture office Weissenrieder Architekten BDA. The front-end uses UIkit 2 and Isotope for the projects overview. Every project category can be accessed in the overview with an URL segment. ProFields Table was used for the project detail view.
      Modules used:
      AdminThemeUIkit Table ProCache Markup Sitemap XML Email Obfuscation (EMO) Jumplinks Tracy Debugger Regards, Andreas
    • By jploch
      Hey guys,
      Just launched a new project called Fabricius:

      Fabricius is a new building thats being built in Hamburg (Germany), that offers modern living comfort in a green environment. 
      I developed the whole brand strategy and visual identity for the website and some printing materials. 
      The logo mark is derived from the silhouette of the building, which is surrounded by trees (circular shapes) and green areas.
      More details here

      The website is build with PW 3.0 and uses Modules like Map Marker, Pages2PDF (to generate the apartment exposes) and MarkupSrcSet.
      Thanks for the awesome support here and the development of PW and the modules!!
    • By sudodo
      Note - I've not set this up, I'm not experienced, I'm probably omitting much
      relevant information as a result so this post will be a bit of a work in
      progress. The answer may be on the forum here - If it is I can't tell for lack
      of experience (I've looked).
      I cannot for the life of me get an install to work and I've tried a lot, and
      I've asked others who're also struggling but I'll try posting here before
      another CMS as I've heard it's nice.
      Info about the server : https://gist.github.com/65086fbc7b5dd03abd0f0461b9c0ec8b
      I'm using the `stable` version of Processwire.
      My `htaccess` file is working - you can test here http://rightangle.space/ and
      click on the admin page to see the internal server error.
      Here is the htaccess file https://gist.github.com/3b805b8ab3c7978aca90a6e39773da00
      Here is the /etc/apache2/apache2.conf file https://gist.github.com/2b2f2518ce7df4af4739413bc967cf56
      Here is the /etc/apache2/sites-enabled/000-default.conf file https://gist.github.com/400cc958ff32dfb6df80693fd8531f08
      Here's the output of  tree -fa /var/www/ https://gist.github.com/a3569becd9889b4b05c4f0d0a8a561d7

    • By mrjasongorman
      I have a friend who uses Silverstripe, and he was telling me about the Data Objects and the ORM it uses, for things like "has many", "one to one", "one to many" relations etc.
      Maybe i'm not thinking about things correctly, but in the Processwire world, would a Page essentially be a data object?
      Just want to get my head around how to think about structuring a web application in Processwire.
      I'm familiar with traditional MVC (rails, code igniter) based structures.
      The API may already enable this kind of functionality, but i was wondering if not, would Processwire ever get an ORM? or can an ORM be bolted onto Processwire?
      If anyone could help me figure this out that'd be great.
  • Create New...