Home Joomla Extensions Plugins Difficulty Rating

Difficulty Rating

Difficulty:

Background

While we were working on an Exercise & Fitness website the client had a request for some of the articles - containing details of specific exercises and workouts - to have difficulty ratings showing on each article and also, more discretely, on the category blog-listings.

Technicalities

The plugin searches the article for a tag like:

{ difficulty }2{ /difficulty }

(without the spaces). It replaces this with an empty string and returns a <div> containing the difficulty rating as an image. We used 5 images of dumbells to represent the difficulty of each exercise but this plugin would be easy to extend to any number or different application - just need to change up the images and maybe play with the css style sheets so it fits.

To only show the rating when inside the main article, simply put the above tag below the read-more part of the article.

Changelog

Version 1.01 (25-07-2009)
Thanks to Baby_lone for pointing out that the plugin would return an undefined variable on pages which had no difficulty rating. Very small bug now fixed.

Download & Demos

Difficulty Rating Version: 1.01 Download
GNU/GPL This e-mail address is being protected from spambots. You need JavaScript enabled to view it Homepage 2009-06-04 English Joomla 1.5 23.1 KB459
 

You can see this plugin installed and working on this page. It has been activated by putting the above code into the intro-text (in fact directly after the first paragraph). On this, the full article page, you also see the caption alongside the image. If you click here you will see the blog style of the plugin (without the caption).

Comments

avatar baby_lone
Hello !

I have just found this plugin which is exactly what I was looking for !!

I have two questions though :
- How can I change the images ?
- I have added the tag on one item only, for test purposes. It displays well on the item, but all other items now have the following error : "Notice: Undefined variable: html in C:\wamp\www\joomlacc\plugins\content\difficulty.php on line 63" Does it mean that once the plugin is enabled I have to set up a rating for ALL articles ?

Many thanks in advance for your help, and once again cheers for that great plugin =)

Baby_lone
Name *
Email (For verification & Replies)
Code   
ChronoComments by Joomla Professional Solutions
Submit Comment
Cancel
avatar Tom0
Hi Baby_lone,

Glad you're liking the plugin.

To change the images just replace the ones in [public_html]/plugins/content/difficulty/images with whatever you want. You need to keep the names the same though unless you want to change the plugin code also.

Good spot for the other one, line 63 needs moving up above the "}" -- I will repackage this and release a v1.01 very soon! (This shouldnt give an error on most production servers anyway but it is bad form to return an undefined variable!!)

Tom
Name *
Email (For verification & Replies)
Code   
ChronoComments by Joomla Professional Solutions
Submit Comment
Cancel
avatar Baby_lone
Hey Tom,

Thanks for the super-quick answer ! I will try all this asap and keep you informed. (I will probably have further questions down the road...).

Cheers =)

Baby_lone
Name *
Email (For verification & Replies)
Code   
ChronoComments by Joomla Professional Solutions
Submit Comment
Cancel
avatar Baby_lone
Ok, one more question already =)

Is there anyway I could add several ratings into a same article ?

(I'm thinking a rating a little like what you may have a some hotel websites :
- Localization = 3 stars
- Value for price = 4 stars
- Breakfast = 2 stars
etc...)

Thank you so much !

Best,

Baby_lone
Name *
Email (For verification & Replies)
Code   
ChronoComments by Joomla Professional Solutions
Submit Comment
Cancel
avatar Tom0
Hi Baby_lone,

I like the idea! It is definitely possible, but unfortunately I dont have the time at the moment to do this for free! Send me a message through the Contact page if you would like to talk about paid work.

Otherwise have a look at the plugin code (its pretty simple) and you could pretty much just copy the bulk of the code 3 times over (from the $regex= line down to the $article->text = preg_replace(..) line) and change a few things like the $regex variable which is searched for (ie change "difficulty" to "breakfast") and also the line which puts the images in (so you can have different icon sets for each one. Then you will be able to set {breakfast}4{/breakfast} as well as in each of your articles.

Does that sound easy or what?! If you have trouble let me know. If you get it working let me know also I'd love to see it in action.

Tom
Name *
Email (For verification & Replies)
Code   
ChronoComments by Joomla Professional Solutions
Submit Comment
Cancel
Name *
Email (For verification & Replies)
Code   
ChronoComments by Joomla Professional Solutions
Submit Comment