[Elgg 1.8-1.12 & 2.X & 3.X: Elggx Fivestar] v1.8.2

Release Notes


  • French translation added (thank to emanwebdev),
  • German translation added.

There are some default views defined where the voting widget will appear on your Elgg site. If you want to change the configuration, remove the voting widget from certain views or add it to others, please read README.txt for instructions on how to proceed.

  • Is it possible to add these fivestars to a group so that people can give their rating on a group?

  • @Tauvic Ritter:

    Yes. It's possible. You can try by adding the following fivestar view (either via Administer - Utilities - Elggx Fivestar in the admin section of your site or by adding this view to the dafault views in start.php of the Fivestar plugin):

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

    The Fivestar rating widget for groups will then appear on the group listings page (also in widgets that list the groups) and in the sidebar on group pages (group profile etc.).

  • Excellent plugin!  I've figured out how to get the rating to display on the main izap-video view page but I'm having some problems getting a rating to appear on the video listing so people can see the rating of the video before clicking on it.  The other old plugin suggested it was in 'izap_videos/views/default/izap_videos/listElement.php' where it could be changed but it looks like that may have been moved in more recent izap video versions.  Does anyone else know where to look or perhaps has some other hint if they have done this before?  Thank you.

  • There surely are several ways how to get the rating widgets to show up properly for the izap_videos plugin. Unfortunantely, the easiest way to achieve this (like with other types of entities) via the Elggx Fivestar settings page does not work. To be honest... the code of the izap_videos plugin is very, very complex and confusing. I'm not even sure if you might be able to delete quite a number of its files without losing any functionality...

    How I got it working:

    • For rating widget to be included on single video view page: modification of mod/izap-videos/views/default/izap-videos/view/video/elements/description.php:


    <div class="description">
          <div id="small_desc">
            /// description text
            if(strlen($description) > 255) {
              $mini_description = strip_tags($description);
              echo substr($mini_description,0,255);
              echo '... &nbsp;&nbsp;&nbsp;<a href="#fulldesc" onClick="show_full_desc();" class="more_less_link">['.elgg_echo("izap_videos:more").']</a>';
            }else {
              echo $description;
            if (elgg_is_active_plugin('elggx_fivestar')) {
                echo "<br>" . elgg_view('elggx_fivestar/voting', array('entity'=> $vars['video']));

    • For rating widget to be included on video list page: modification of mod/izap-videos/views/default/object/izap-videos/elements/summary.php:

    $metadata = elgg_extract('metadata', $vars, '');
    $subtitle = elgg_extract('subtitle', $vars, '');
    $content = elgg_extract('content', $vars, '');

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

    $tags = elgg_extract('tags', $vars, '');

    • For rating widget to be included on video list in izap_videos widgets: modification of mod/izap-videos/views/default/object/izap-videos/mini.php:

      $info = elgg_view('page/components/summary', array(
              'entity' => $video,
              'tags' => FALSE,
              'title' => $title,
              'subtitle' =>  elgg_get_friendly_time($video->time_created) . ' ' .elgg_echo('by') . ' ' . elgg_view('output/url', array(
                      'text' => $video->container_name,
                      'href' => IzapBase::setHref(
                                  'action' => 'owner',
                                  'page_owner' => $video->container_username,
                                  'context' => GLOBAL_IZAP_VIDEOS_PAGEHANDLER,
              )) .  ' ' . elgg_echo('izap_videos:views') . ':<b>' .$video->getViews() . '</b>',
      if (elgg_is_active_plugin('elggx_fivestar')) {
        $info .=  elgg_view('elggx_fivestar/voting', array('entity'=> $video));
      echo elgg_view_image_block($icon, $info);

    Remark regarding adding the rating widget to widgets: I've noticed while working on another plugin that the rating widget only is displayed correctly, if the corresponding Elgg entity (video, blog, file etc.) is only shown once per page. So, if you have the same entity to appear twice or more often for example within two different widgets on the same page (for example the izap_videos plugin offers two widgets: "My videos" and "Latest videos") you will get the rating widget only added to one of them correctly. In the other cases the stars and therefore the option to vote will be missing. I've got to figure out what exactly is causing this issue. If I find out how to fix it I'll release a fixed version. Unfortunately, I can't give any timeline for that...

  • iionly, thanks for your work.  It's working now. :)  In case it helps anyone else who might read this I opted to use this variation for the video listing page:


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

    I thought it looked better on the template I used.  Instead of at the end of the content it puts the rankings to the left of the tags for me and I opted to use 'min' => true.  I did not notice any side effects on Firefox or Chromium.

  • please post source for activity .

  • @raio: adding a 5-star rating to items in the activity river is not as easy as adding it to other parts of an Elgg site. You also need to know that it's not possible due to underlying Elgg data model to add a rating option to all items. For example you can't rate Elgg comments as they are "Elgg annotations" and the rating only works for "Elgg entities" (= kind of the parents of annotations). For other river items the rating wouldn't make much sense - for example for "relationship" items (User A is now friend with User B etc.).

    It might work to add rating widgets to river items by extending the item view. Another possibility would be adding the rating widget to the entity menu (though this option could result in some rather annoying page layout issues as it could lead to ugly line breaks in the entity menu).

    If I have a bit of free time I might try to get the rating widgets to show via extending the item view for river items. But I can't give any timeline yet and I can't promise that it even works this way!

  • hi, in my website i have 2 subtypes of users : companies and users. I want the companies to be able to rate the users ( from there profile maybe under the avatar ) and the users to rate the companies profile.
    Can you tell me:
    1- how to add the view to display the 5 stars under avatar in profile

    2- how can i allow users to rate ONLY companies profiles and companies to rate ONLY users profiles

    i know this is too specific but any help would be appreciated (maybe tell me which part of the code to change)


  • @Cyril: to allow user rating you can add the following view in the Elggx Fivestar settings:

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

    This will display the rating widget below user icons of size "large". As the large user icon is normally only shown on the profile page of a user the rating widget will only be included there, too.

    This method does not take into account the account categories (and without testing this out: I think it also allows a user to rate himself/herself). If you want to restrict the voting to the other account type respectively, you can't achieve it by adding a view only. You would need to modify the voting algorithm in elggx_fivestar/views/default/elggx_fivestar/voting.php. Check out the code in this file and take a look especially in this part:

    $disabled = '';
    if (!elgg_is_logged_in()) {
        $disabled = 'disabled="disabled"';

    if (!(int)elgg_get_plugin_setting('change_cancel', 'elggx_fivestar')) {
        if (elggx_fivestar_hasVoted($guid)) {
            $disabled = 'disabled="disabled"';

    The first if-clause checks if a user is logged in and prevents voting if not. The second if-clause checks if re-voting is allowed and prevents it if not. What you would need to add is a third if-clause that checks if the logged in user is of the opposite account type and prevent voting if the type is the same.

    Actually, you would need to do some more specific checks, too:

    • $vars['entity'] is the Elgg entity that is voted on. You would need to make sure that the Entity is an Elgg user first. Otherwise the account category check is not necessary anyway.
    • Then you might also include a check if $vars['entity'] is not the logged-in user. Otherwise the voting should be blocked.
    • At last check the account category of $vars['entity'] and compare it with the category of the logged in user.
    • Prevent the voting by assigning $disabled = 'disabled="disabled"';
  • @iionly, can you tell me where I'd find the Elggx Fivestar settings page to make this change:

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

    Is this in the Views folder? 


  • @Lark2: the "elggx_fivestar_view" is not a view itself but the name of the variable used internally to save the configuration to which views the rating widget should be added to (and where exactly inside this view).

    There are two possibilities how you can add a new definition like the one you are asking for. The first possibility works without modifying any code. In the admin section of your site there's the section "Administer" - "Utilities" - "Elggx Fivestar" that you can open via the right hand side menu. On this page click on "Add view" and insert the definition (i.e. the line you included in your posting) in the new input field. Then click on "Save" and the new fivestar view definition should show up (in this case on the profile pages below the profile picture).

    The second possibility would be to add this line to the $elggx_fivestar_view array in start.php of the Fivestar plugin. This array is defined in the function elggx_fivestar_defaults() with some defaults where to add the rating widget. This function is almost at the end of start.php.

    These two possibilities have the same pros and cons basically. The definition of new views works in the same way and you don't need to modify any code of other plugins (of plugins you want the rating widget to be used). The configuration via the admin section is maybe the faster (or more comfortable) way but you would need to add new views on a new site again while they would be already pre-defined if you do it by definition in start.php.

    These two possibilities also have the same limitation if you want to define exactly where the rating widget should appear and in some cases it's not possible at all this way (like for example in the new Tidypics versions for Elgg 1.8). For it to work you need to be able to provide some identifier (html tag and corresponding value) that is within the Elgg view the rating widget will be added to. For example, if the view code includes a <div class="elgg-avatar elgg-avatar-large"> then add the rating widgets after that. If this fails (Javascript / Ajax involved) or the placement is not exactly enough, you would need to modify the corresponding view code of the plugin involved by adding a

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

    at the preferred location in the code with the variable name "$entity" changed to whatever variable name that is used for the Elgg entity in question in this view.

  • Wow, okay, I will plow through this and try to figure out. I went the "Add View" route but I don't see any stars below the large Avatars on members' profiles. So I will try the other way. I am new to Elgg, so I am seeing stars, just not the right ones. -)

  • THANK YOU, iionly! I followed your instructions and figured it out. Thanks again!!


  • Is it possible to rate Discussion Thread Replies? 

  • @Charles: no. Discussion replies are saved as Elgg annotations in the database (with all replies / annotations belonging to the Elgg entity that is the starting post of the discussion thread). The Fivestar plugin can only be used to rate on Elgg entities (e.g. the first post of a thread). The ratings itself are also saved as annotations belonging to this entity.

    With Elgg 1.9 the situation most likely will change, i.e. all comments (and maybe also replies in discussions) will be saved itself as separate entities, too. Most likely I will take a look on this and most likely will release a new version of the Fivestar plugin if there are any new possibilities in this area on Elgg 1.9 once it got released.

  • @iionly - Thanks for hte quick reply!  I will upgrade and wait for 1.9...


  • Category: Misc
  • License: GNU General Public License (GPL) version 2
  • Updated: 2020-8-23
  • Downloads: 10766
  • Recommendations: 31

Other Projects

View iionly's plugins