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?



Share this post

Link to post
Share on other sites

Welcome to the forums!

I'd suggest you take a look at this (pro) module by Ryan: 

It may save you a lot of time and possible headaches :)


Share this post

Link to post
Share on other sites

Thank you for that suggestion. However the headache is part of learning the platform, so I'm accepting it. 

  • Like 3

Share this post

Link to post
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

Share this post

Link to post
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 3
  • Thanks 1

Share this post

Link to post
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
      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.
    • By Sephiroth
      Hi guys am a complete Noob to Processwire and i have spent the past two weeks reading codes and understanding the structure and concept around it. So i am the type of dev who obesseses about architecture structure before getting to work, and i think my mind is broken due to my limited knowledge on PW. So i will expain my goal.
      I intend to rebuild http://styljunki.com from Wordpress to Processwire because of two reasons.
      1. PW has no templating system meaning no hacks like shortcode or mundane template conventions.
      2. Modules dependency meaning i can leverage on existing modules (easily) e.g wire('moduleName')->method this really appeals to me alot
      However there are certain tasks i want to achieve.
      Concept of Blog vs Pages
      There are some contents which are Post and some which are pages, is there some such dinstinction in PW, I know PW manipulates pages and adds fields but what of Blogs which just take entry and nothing special, I tried my hands on the Blog Module on PW 2.5.8 but it threw some errors.
      Menu Management
      My Client intends to manage menus and from what i have seen ; PW lists all the pages, we were looking for something where we  can simply create menus for the front page and we simply pick those. But if there's a module around I am willing to use/ contribute code if it is neccessary.
      Custom Post
      In Wordpress you can create a custom post and query that, is there any similar thing to that ?
      Unit testing
      PHPUnit Testing in WordPress was a big joke, is there any link to unit test processwire while we work
      Thanks this are my questions
      Also i'd really like to say congrats because, I have spent the 4 years of my life developing with CMS from Joomla,WordPress,ImpressPages and really this is the first time i am really excited about a CMS.
      Working with WordPress as a CMS is a pain in the ass, esp for someone used to MVC frameworks like Zend and Yii. I have searched and searched till i came across your site on CMSCritic and Joss Salinger 's post the rocker blogger (rock on) on how easily he could use it despite no coding experience. I intend to contribute in my way. Keep up the good work guys. Love from Nigeria
  • Create New...