Log in

Stats

  • Category: Misc
  • License: GNU General Public License (GPL) version 2
  • Updated: 2013-11-3
  • Downloads: 3081
  • Recommendations: 24

Other Projects

View iionly's plugins

[Elgg 1.8+1.9: Elggx Fivestar] for Elgg 1.8

Elggx Fivestar adds a clean, attractive voting widget to Elgg.

Last updated 168 days ago

This is an updated version of Divagater's Fivestar voting plugin (http://community.elgg.org/pg/plugins/project/385091/developer/divagater/fivestar) to work with Elgg 1.8 (version 1.8.X) and Elgg 1.9 (version 1.9.X).

This plugin will add a voting widget to certain views on your site, for example blogs, pages, bookmarks, files and group discussions. By default the voting widget will display 5 stars but you can configure the number of stars to show. You can also configure if your members should be allowed to change their vote or not.

Installation:

(0. If you have installed a previous version of the Elggx Fivestar plugin disable the plugin in the admin section of your site and then remove the elggx_fivestar folder from the mod directory of your Elgg installation,)

  1. Copy the elggx_fivestar folder into the mod directory of your Elgg installation,
  2. Enable the plugin in the admin section of your site,
  3. Configure then the plugin settings (section "Administer" - "Utilities" - "Elggx Fivestar"). At least it's necessary to add the rating widget to some views for the Elggx Fivestar plugin being useable. Via the plugin settings you can add the rating widget to some pre-defined default views. In the following is described in detail how the configuration of the rating widget for more views works in detail.

Which version of the plugin to use on which version of Elgg?

If not stated otherwise the first two numbers of the plugin version will indicate the compatible Elgg version, i.e.

  • plugin version 1.8.X is for Elgg 1.8 while
  • plugin version 1.9.X is for Elgg 1.9 respectively (and so on for future versions of Elgg).

The third number in the plugin version will indicate the actual plugin version, i.e. two plugin versions numbered for example "1.8.1" and "1.9.1" (or "1.8.2" and "1.9.2" etc.) should basically have the same features but only differ in API code that is specific to the Elgg version the plugin is compatible to.

If there's ever a fourth number in the plugin version, this version will only include fixes in the plugin necessary for the corresponding Elgg version, i.e. a plugin version "1.9.1.1" would fix some Elgg 1.9 specific issues of version "1.9.1" while such fixes would not be necessary for example for the corresponding version of the plugin for Elgg 1.8 (so there would be not release "1.8.1.1" necessary).

How to customize it:

To include the rating widget on your site after enabling the Elggx Fivestar plugin for the first time (or after upgrading from a version of Elggx Fivestar < 1.8.0) you need to set the default views on Elggx Fivestar's plugin settings page in the admin section of your site ("Administer" - "Utilities" - "Elggx Fivestar"). Click on "Set / Reset default views" and save the settings. There are already some default views defined in start.php where the rating widget will be included on your site, for example on blogs, pages and group discussions.

You can also configure on your own where the rating widget should appear. Either you can define additional views to include the widget on other pages or remove the rating widget from certain pages. If you are not happy with any of the default views and want to remove it you can do this in the plugin's setting page by removing the corresponding view. Or you can adjust the default views defined in start.php of Elggx Fivestar (function elggx_fivestar_defaults() starting at line 260) and then resetting the views on the settings page.

If you want to add the rating widget to a view you can also do this either via adding the view directly via the settings page or again by adjusting the default views in start.php. You will need to have some knowledge about the php/html code of the view you want to add the rating widget to be able able to define the correct position. The already defined default view should give you an idea how it works.

If you want to add a new view via the settings page the code to be included has to start with

elggx_fivestar_view=

followed by the parameters to identify the view.

The method for adding the rating widget to a view as used by the defined default views or any other views you define via the settings page / start.php requires a distinct html or css tag to define the position the rating widget will be included on the corresponding page, either before or after this tag. Sometimes, this method might not be appropriate to define the exact position desired for the rating widget. There's also a second way to add the rating widget to a view that allows exact positioning. You need to modify the code of the view for this method to work.

Simply add the following at the appropriate place in your plugin code and adjust the parameters accordingly:

echo elgg_view("elggx_fivestar/voting", array(    'entity' => $entity,    'min' => true,    'subclass' => 'fivestar_subclass',    'outerId' => 'fivestar_rating_list',    'ratingTextClass' => 'fivestar_rating_text'));

The above code snippet includes all possible options to configure the voting widget. These are:

  • 'entity' => $entity: This defines the entity to be voted on. The variable $entity must be assigned the correct Elgg entity in the code prior calling the voting widget.
  • 'min' => true: If set to true, the voting widget will be bare only showing the stars to vote on and not the current voting stats (number of votes and average vote) for this entity.
  • 'subclass' => 'fivestar_subclass', 'outerId' => 'fivestar_rating_list', 'ratingTextClass' => 'fivestar_rating_text': These options allow you to configure the layout of the voting widget via CSS settings defined for example in Elggx Fivestar's css file (in elggx_fivestar/views/default/css/basic.php). The strings are the identifiers of the css classes and you have to define the classes prior using them.

The simpliest way to include the voting widget in the plugin code is by only giving the entity to be voted on as parameter:

echo elgg_view("elggx_fivestar/voting", array('entity' => $entity));

In this case the default css layout of the voting widget is used. Still, you must assign the correct entity to the variable $entity in any case.

Release Notes:

Changelog:

  • Fixed error in activate.php,
  • Updated simple_html_dom.php library.

Comments

  • S.Brady.Hussain 158 days ago

    thank you : )

  • ansheng 100 days ago

    was able to add to user profile but what is the code for adding it to the members list, hopefully beside the avatar

  • iionly 100 days ago

    @ansheng: You could try it with adding the view

    elggx_fivestar_view=user/default, tag=div, attribute=class, attribute_value=elgg-subtext, before_html=<br />

    This adds the rating widget at least on the members' listing pages. But I have not checked if this will add the rating widget to listings of user entities on other pages, too - it would be added everywhere the "user/default" view is used. If you don't like the position the rating widget gets added you should look at the html source code of the members' listing page in your browser to identify possible alternative positions. You would have to look at the css class names used on this page within the listing of a single user and then select one as alternative to "elgg-subtext".

  • Gerard 88 days ago

    When use this plugin I get the following error:  "Uncaught SyntaxError: Unexpected end of input"

    As a Consquence some of my jquery code is stumbling on that error causing the page not being loaded correctly.

    I tried to find the cause, but haven't found it yet. 

  • iionly 88 days ago

    @Gerard: I haven't got this error so far. Do you have the jquery code included in some published plugin? Then I could try to reproduce the problem.

  • Gerard 88 days ago

    The jquery is very new code, but it is not published yet. Anyway, since it was new code, it  also was my first suspect. But it wasn't, I disabled it and the error was still showing but did not interfere with the page look anymore. It looks that it only appears with tidypics (while viewing a picture), so that plugin could also be the cause of the problem. I currently exclude fivestar rating from pics.

    You should be able to reproduce the problem, enable five star rating and open some pics (not listings).

    I used Chrome devTools to find the error. It will immediately show as error on the top bar.

  • iionly 87 days ago

    @Gerad: I'm sorry but I can't reproduce. I've tried it with Elggx Fivestar v1.8.6 and Tidypics v1.8.1beta12 on Elgg 1.8.18 with the Tidypics-specific rating views

    elggx_fivestar_view=object/album, tag=div, attribute=class, attribute_value=elgg-subtext, before_html=<br>
    elggx_fivestar_view=object/image, tag=div, attribute=class, attribute_value=elgg-subtext, before_html=<br>

    but there was no "Uncaught SyntaxError: Unexpected end of input" error in the debug logs - actually no error at all.

    If the error would be due to the Fivestar plugin I would also be a bit perplexed if the error would only occur on the Tidypics' image pages as the handling of the ratings on images is not really any different from rating other types of entities. I can only guess that maybe yet another 3rd party plugin is involved and that this other plugin together with the Fivestar plugin (and/or with Tidypics) results in the issue. But I have no idea what other plugin could be involved. I got reports that the bad word filter plugin installed makes Tidypics unuseable (errors on uploads) and I think I remember someone saying that there's an issue with an ajaxed comments or ajaxed live notifications plugin and image tagging of Tidypics images (I don't remember at the moment which plugin caused this issue. Could be an "hype" plugin but I'm not sure).

    Could you test if the error with rating on Tidypics' images also occurs with no other 3rd party plugins enabled - and using the latest releases of Fivestar and Tidpics with the default rating views for Tidypics? If you could narrow down the circumstances involved it might make searching for a solution easier.

  • Gerard 87 days ago

    I am not sure we are on the same page. I use the instructed code to include, well what I understood from it, which is:

    if (elgg_is_active_plugin('elggx_fivestar')) {
            $subtitle .= elgg_view('elggx_fivestar/voting', array('entity'=> $vars['entity'], 'min' => true));
            $subtitle .=  "  ";

    }

    I us a little bit older version of tidypics 1.8.1 beta7 on Elgg 1.8.17

    What do you suggest I change ?

  • iionly 86 days ago

    @Gerard: I think I understand now the problem. The code of the Tidypics plugin you posted is commented out by default. It's an alternative way to display the rating widget on image pages. I had added these lines of code before implementing a default rating view for Tidypics' images in the Fivestar plugin. After I had added the default view I commented out these lines in the code of Tidypics and added the comment line telling about this being another way to get the rating widget to be added to the image pages.

    You have now both the default rating view added to the images pages plus the alternative code. While each method works without problems when used as the only method it fails to work correctly when both methods are used at the same time. I never thought anyone would try that... Well, I will remove these lines of code for the next release of Tidypics.

    You should now either comment out these lines of code again in the code of the Tidypics widget or you should remove the "object/image" default view from the list of views the rating widget is added to in the Elggx Fivestar plugin settings. I would suggest to comment out the code as the default view will add the rating widget to the images on the same location on the page it's also added to the other types of entities like blogs and files. Btw. I would suggest to upgrade Tidypics to the latest release because there are a number of other issues fixed in the meantime. It should be without risk to upgrade as you are on Elgg 1.8.17 already. And ugrading to Elgg 1.8.18, too, would fix the problem with some notifications not being sent (a bug introduced with Elgg 1.8.17).

  • Gerard 85 days ago

    Ah that works indeed. I use that code on videos too, should I do that differently ?

    About 1.8.18, I solved the notificiation issue before that update was there. So no need to update for now.

    There is also another little strange thing with fivestar. When scrolling down on a list, new content is loaded with jquery but in that new loaded list the fivestar rating show in a different format.

    If you check for instance this page https://www.centillien.com/videos/mostviewed and scrol down you can see what I mean.

     

     

  • iionly 85 days ago

    @Gerard: the point is to use only one method at a time for displaying the rating widget on a view. To be honest I've not yet tested the fivestar voting for videos. But it should work both ways, i.e. either by adding a view in the Fivestar plugin settings or by including the voting view directly in the code of the videos plugin.

    The problem with the jquery loading of list entries seems to be caused by the Fivestar css not being loaded for the additional list entries that are displayed only when scrolling down. I haven't tested the Fivestar plugin with any plugin that adds additional entries on demand only yet. May I ask which plugin you are using to be able to test this myself?

    Maybe it will help if you load the Fivestar css and js library already in start.php of the Fivestar plugin instead of only within views/default/elggx_fivestar/voting.php. But without knowing which plugin you use on your site to add more list entries via jquery I can't test this myself.

  • Gerard 85 days ago

    The plugin I used for this is infinite scroll. http://community.elgg.org/plugins/869769/0.4/infinite-scroll

  • iionly 84 days ago

    @Gerard: I've tested it with the infinite scroll plugin and also with the watch my pages plugin. The problem is that the Fivestar css does not get loaded (not even when extending the Elgg css view in start.php of the Fivestar plugin with the Fivestar css). The js library of the Fivestar plugin gets loaded though so voting on the additonally loaded list entries works. I don't know why the css file of Fivestar is not loaded while loading the js library works obviously. Unfortunately, it's beyond my knowledge to fix this - I don't even know why it's not working. Maybe it would help for you to ask on the infinite scroll or watch my pages plugin pages if the developers of these plugins have an idea why it's not working and can suggest a way to fix it (either by modification of the Fivestar plugin or modifying their plugins).

  • iionly 84 days ago

    @Gerard: it seems the problem of the css style of the Fivestar plugin not being loaded via ajax is a problem of Elgg 1.8. This problem seems to not occur on the upcoming Elgg 1.9 anymore. I've tested it with the watch my pages plugin and the layout of the rating widget was okay also for list items loaded via ajax. Though the watch my pages plugin will require some updates on its own to be fully compatible with Elgg 1.9 (due to use of deprecated functions). The infinite scroll plugin might work without changes on Elgg 1.9. Though it has a problem of its own when used on sites that are installed in a subdirectory.

  • Gerard 84 days ago

    Thanks, I have a 1.9 version running for dev and testing. Many plugins have issues there still and most developers are waiting for a final release before fixing it. I'll live with it for now :-)

  • Michele 72 days ago

    Hi iionly, great plugin, thank you also for this!

    In settings I see "Allow users to change or cancel their votes?" and set it on "Yes" but then I see no actual option to cancel votes (changing votes works fine but cancel doesn't). Am I missing something somewhere? I searched here on the community and nobody reported it so I guess I don't see where/how to cancel votes.

    Cheers

  • iionly 72 days ago

    @Michele: right now it might rather be read as "Allow users to change their votes?" only. The canceling of votes is not fully implemented. I see in the code that the canceling of votes is at least partly implemented but there's at least a "cancel" option that would show up on the rating widget missing. I don't know at the moment if this had never been implemented in the original version of the rating plugin (for Elgg versions < 1.8) or if I might have removed the cancel / delete vote link when porting the plugin to Elgg 1.8. But I surely did forget to sort this out in some way.

  • Michele 71 days ago

    Ah ok thanks for replying, have a nice weekend

  • Michele 54 days ago

    Hi iionly!

    I was just thinking that this nice plugin could be very useful in large communities also if some statistics were available.

    For example a page publicly or admin's only available (option in admin area to chose from?) listing all posts/items ie. 5-starred or all with a sorting option 5->1/viceversa.

    What do you think? Hope this is not a duplicate/too complicated/unuseful idea :)

    Cheers

  • iionly 53 days ago

    @Michele: I can't say how difficult or trivial the implementation would be. I don't know if it would make much sense to simply listing all different kind of content in a single list anyway. So, part of the difficulties would also be the "presentation" of the results.

    I'll keep the idea in mind but I can already say now that I won't have time to experiment with this feature in the foreseeable future.

  • Michele 52 days ago

    @iionly, as always thank you very much for reading, replying and keeping in mind this idea.

    Yes, I definitely agree that presenting the results would be something to think about that's why as initial idea a list could be enough imho.

    Understand the...forecast :)