Jump to content
Sign in to follow this  
Vasilij Zadov

Is it possible to change review rating from 1-5 to text Excellent

Recommended Posts

Is there a way to change review rating stars/bars value from 1-2-3-4-5 to display Terrible-Poor-Average-Very Good-Excellent? I know there is nothing built it at the moment (however, could be a good one to have in the future), but can you please let me know where I can amend it, if that's possible?

 

 

Share this post


Link to post

Joomla: /components/com_jreviews/jreviews/views/helpers/rating.php

 

WordPress: /wp-content/plugins/jreviews/jreviews/views/helpers/rating.php

 

function options

 

There you'll find this comment and commented code that you can adjust to your needs

// You can customize the text of the options by commenting the code above and using the one below:
//              $options['na'] = 'N/A';
//		$options[1] = 'Terrible';
//		$options[2] = 'Not so bad';
//		$options[3] = 'Just ok';
//		$options[4] = 'Good';
//		$options[5] = 'Excellent';

Keep in mind that this is only for the review form and changing it elsewhere would require making other changes that I cannot detail here because I would actually need to spend time figuring it out. But this is the file where all rating output is handled so you can explore it if you want to make additional customizations.

Share this post


Link to post

If you use this trick, the setting is no longer relevant because you are overriding it. So yes, you would need to add more options for the half points.

Share this post


Link to post

I am no longer seeing this code in jreviews 3.5 rating.php:

// You can customize the text of the options by commenting the code above and using the one below:
//              $options['na'] = 'N/A';
//		$options[1] = 'Terrible';
//		$options[2] = 'Not so bad';
//		$options[3] = 'Just ok';
//		$options[4] = 'Good';
//		$options[5] = 'Excellent';

How can the same thing be done in 3.5 version?

Share this post


Link to post

The code in JReviews 3 was improved and re-organized so now all the review helper methods reside here

/components/com_jreviews/jreviews/views/helpers/review_helper.php

The function name is ratingOptions. In the next update I am going to add a new developer filter named "review_form_rating_options" which is going to allow you to make this customization without having to modify any core files. You'll be able to use this code inside your filter_functions.php file.

function review_form_rating_options($options, $params)
{
	// Uncomment line below to dump filter arguments to the screen
	// dd($options, $params);

	$listingTypeId = S2Array::get($params,'listing_type_id');

	$reviewType = S2Array::get($params,'review_type');

	$required = S2Array::get($params,'required');

	$scale = S2Array::get($params,'scale');

	$increment = S2Array::get($params,'increment');

	$options = [];

	if ( !$required )
	{
		$options['na'] = 'N/A';
	}

	$options[1] = 'Terrible';
	$options[2] = 'Not so bad';
	$options[3] = 'Just ok';
	$options[4] = 'Good';
	$options[5] = 'Excellent';

	return $options;
}

Since you have the $listingTypeId you'll also be able, if needed, to use different text for different listing types. I am also retrieving other variables available there that you can use to build your own logic like scale, required, review type, etc.

Share this post


Link to post
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Please refer to our Privacy Policy.