38

Displaying rating results

Thumbnail for Displaying rating results

Widgets are not the only way to display list with rating/review results. You can add results into post (using shortcode) or anywhere in the theme you want (using function). This is first post to go deeper into this type of rendering. More to come soon.

Template I am going to make here will be added as additional with next version of the plugin. Styles will be kept at minimum, so that you can style it the way you want on your own. Before we get to adding shortcode or function, we need to prepare template. Template you need is Standard Ratings Results (SRR). This template has the same tags and is rendered by the same functions as the template for widget. This template has 3 elements: header, footer and item. Item will be used to render each results row. Our results table will have 4 columns: Rank, Title, Votes and Rating. Rank is the simple numbering staring for 1 to number the rows. Title is the post title, and Votes and Rating are self-explanatory. For rating we will use rating stars.

Header element:

<table class="tplresults"><thead><tr><td></td><td>Title</td><td class="votes">Votes</td><td>Rating</td></tr></thead><tbody>

Item element:

<tr class="%AUTO_ROW_CLASS%"><td class="rank">%RANK_ID%</td><td><a href="%PERMALINK%">%TITLE%</a></td><td class="votes">%VOTES%</td><td>%STARS%</td></tr>

Footer element:

</tbody></table>

So, once the template is created, we need to add some styles. I suggest adding styles into themes style.css, because in most cases styles depend on the theme and is good idea to keep the in the same file. Here is the CSS you can use:

.tplresults { width: 100%; border: 1px solid gray; }
.tplresults img { padding: 0; background: none; margin: 0; border: none; }
.tplresults thead td { background-color: gray; color: white; font-weight: bold; padding: 2px 5px; }
.tplresults .rank { text-align: center; width: 20px; }
.tplresults .votes { text-align: center; }

And here is the result:

TitleVotesRating
1GD Star Rating 1.4.658
2Settings Explained Part 5.33
3Translating plugin using POEdit29
4New website Dev4Press19
5GD Star Rating 1.7.615

This table shows top 5 posts with minimum 15 votes saved, using the newly created template. You can do whatever you want to render results, use any CSS and HTML you want with combination of special tags this template support. And as you can see, there are a lot of tags for this rendering. I can’t go through everything that can be done, but basically this is procedure to get results: create template, add styles and finally add shortcode or use function.

To get the shortcode use either the builder or shortcode button on the editor. For function, use Builder. To get this rendering in both Builder and Shortcode editor button, you need to select StarRating results option, and for template you need to select template you made. For the table above generated function is:

wp_gdsr_render_rating_results(array('template_id' => 47, 'rows' => 5, 'min_votes' => 15));

Template ID will not be the same in your case, so that’s why you need to use Builder, so that the generated code is exact. If you were to use default templates, you will not see rendered stars, and there will be no styles.  For most results rendering you NEED styles made, and I don’t provide that with the plugin, because they will largely depend on your theme.

Next post on the subject will describe use of custom tags with the results and some of the filters to modify results and rendering.

GD Star Rating
loading...
Displaying rating results7.310105

Share this:

RSS DiGG Google Buzz Google Technorati StumbleUpon Design Float Microsoft Live PDF Favorites

38 Responses to “Displaying rating results”

  1. Mike

    August 13, 2009
    at 3:28 AM

    This might be a bad question but after I read it, I am wondering how we could render a multi set in this same fashion.

    I am able to get the multi set to show in the post properly with short codes, but I have tried every function with no luck. If I can use this function that would be nice. I will just have to familiarize myself with the shortcode.

    GD Star Rating
    loading...
    • MillaN

      August 13, 2009
      at 12:18 PM

      If you go through builder options for this, you will see option called Source where you can select multi rating or thumb data also.

      GD Star Rating
      loading...
  2. Mike

    August 13, 2009
    at 3:35 AM

    One more thing. I am able to use wp_gdsr_multi_rating_average to get the average, but it doesnt have a template. Is my only option for customization to use the above example?

    Also to sum up my first post. I am wondering what should be used to render a multi set in the same fashion. ie. template and function.

    Not sure why I am having such problems…

    GD Star Rating
    loading...
    • Mike

      August 13, 2009
      at 4:09 AM

      I think I have answered my own question regarding the rendering of the multi set.

      Use wp_gdsr_render_multi and set the read only to true. I will now experiment with differant templates with that.

      I am still curious however about the multi_rating_average, what is the best way to display that for a single post with a template. Seeing how multi_rating_average does not support a template.

      Thanks.

      GD Star Rating
      loading...
    • MillaN

      August 13, 2009
      at 12:21 PM

      If you read the info file on this function you would see that it renders only stars, nothing else.

      GD Star Rating
      loading...
      • Mike

        August 13, 2009
        at 3:09 PM

        So then what is the best way to get a multi set AVERAGE and still be able to use a template? Use the same method that you mention above?

        GD Star Rating
        loading...
        • Mike

          August 13, 2009
          at 3:13 PM

          Basically I am just looking to add the word votes to the bottom of the multi average.

          GD Star Rating
          loading...
        • MillaN

          August 13, 2009
          at 4:02 PM

          Rendering you need is not available right now. It can be done with multi review, but multi rating function like that is not done. Yet.

          GD Star Rating
          loading...
          • Mike

            August 13, 2009
            at 4:21 PM

            I see, that would be a nice enhancement. It is like amazon, they show how many total voters along with the average, however this would be for a multi review.

            GD Star Rating
            loading...
  3. meda

    August 15, 2009
    at 6:21 AM

    Hi MillaN,

    In the widget, are you planning on making sure the “minimum votes” option are applied to the categories instead of individual posts? That would reflect a true category rating.

    GD Star Rating
    loading...
  4. Mike

    August 16, 2009
    at 3:14 AM

    Hi Milan,

    Sorry to bother you again but I have another question.

    I am continuing development on my rating site(dont worry it isent rating movies/shows) and I placed the wp_gdsr_render_multi in single.php so it shows on every page.

    The problem is some posts are not ratable and only for informational purpose. I looked around in the docs and in the post editor to see if there was a way to disable on a per post basis even if we hard code in our template but came up empty.

    Is there a way to do this? If not is the best way to just place shortcodes in the post?

    THANKS

    GD Star Rating
    loading...
    • MillaN

      August 16, 2009
      at 3:37 AM

      Function you use has a parameter for read only. If you use shortcode, you can see that there is a parameter for that also.

      GD Star Rating
      loading...
      • Mike

        August 16, 2009
        at 3:48 AM

        Ok sounds like shortcodes is the way to go. The other option might be to make all informational/ non ratable posts, PAGES.

        Just wanted to make sure I wasent missing something. This plugin has so much functionality it wouldn’t have surprised me if that was possible.

        GD Star Rating
        loading...
  5. Warren

    August 16, 2009
    at 8:05 PM

    After changing or creating, it wasn’t clear, a (SRR) Template; I was able to render the table but I am unable to render results even though the plugin is active on my page.

    I used the builder to create the shortcode and function as you specified, and coped the function into my template file in my wp theme where I wanted to display the ratings.

    Here is the shortcode that the builder generated:

    wp_gdsr_render_rating_results(array(‘template_id’ => 42, ‘rows’ => 3, ‘category’ => 41, ‘hide_empty’ => false));

    This was intended to display the 3 top reviews of a specific category. Granted there is only post in that catagory, it should still display 1, right?

    GD Star Rating
    loading...
    • MillaN

      August 16, 2009
      at 8:40 PM

      If that post has less than 5 votes, it will not be displayed. That is minimum of required votes by default. Change that and posts will display.

      GD Star Rating
      loading...
  6. Warren

    August 16, 2009
    at 8:46 PM

    Thank you so much, that worked perfectly, you’re the man.

    GD Star Rating
    loading...
  7. Andrei Gheorghiu

    August 30, 2009
    at 1:01 AM

    I’m pretty sure I’ve made a comment earlier today on this post. It seems it offended you.

    Sorry about that.

    I’ll try my luck with another question: Is it possible to use different colors for the stars in the same multi block? (Provided I export them in .png format, of course…)

    I’m not a big fan of tweaking code inside plugins as I prefer them upgradeable.

    GD Star Rating
    loading...
    • MillaN

      August 30, 2009
      at 1:44 AM

      I am deleting comments all the time. I have written many times on the rules, and still I get the same questions. But, this new question is different.

      There is a plan to add this, but at this point is not possible. And hacking the code for this now is almost impossible to do without rewriting rendering of the multis. This will be done after 1.7.0 is released, and that’s still more than month away.

      GD Star Rating
      loading...
  8. rob

    August 31, 2009
    at 6:47 PM

    i used this template/style to display the results and it works perfectly. One question – how do i make it so that a person can vote directly from the results page by scrolling over the stars?- now when u scroll over the stars using the above code it doesnt work, is this possible?

    GD Star Rating
    loading...
  9. David Gu

    September 4, 2009
    at 8:12 PM

    It is good plugin. I will try it in my webpage.
    Do you support list different categories? For example I have two categories, in each category I have several posts, I want to list the two categories in two table according to the rank of the posts within the category.

    GD Star Rating
    loading...
    • MillaN

      September 5, 2009
      at 11:34 PM

      Yes, results can be filtered by the category.

      GD Star Rating
      loading...
  10. David Gu

    September 4, 2009
    at 11:40 PM

    What is Standard Ratings Results (SRR)? Where it located? In your user manual I can not find any information of builder.

    GD Star Rating
    loading...
    • MillaN

      September 5, 2009
      at 11:35 PM

      This is template type used to display ratings results.

      GD Star Rating
      loading...
    • chuck

      September 10, 2009
      at 5:42 AM

      David, it took me a while to get it too.

      It’s the T2 Templates section within the GD Settings in your admin wp-admin. If you click the Standard Rating Results link there, it will automatically create a new template after you rename it and save it, you’ll see the new template ID for that new template. ;-)

      GD Star Rating
      loading...
  11. john

    September 5, 2009
    at 6:42 AM

    hi mike

    just a question about ranking results etc ……..will you ever implement a `current rank` feature in future releases?

    example

    if i have 500 posts listed

    at the end of each post we would be able to see what ranking it has

    example: post #233 `current rank` 18
    post #234 `current rank` 166

    this would be a good way of ranking large list of posts on popularity etc.But enabling the visitor to see where its ranked without leaving the webpage.

    keep up the good work love the plugin!!

    GD Star Rating
    loading...
    • MillaN

      September 5, 2009
      at 11:36 PM

      Rank is a tricky thing, it can’t be a globally valid, it depends on the results context. When you display results there is a tag to display rank (check my TVScape website ratings) in the current results set.

      GD Star Rating
      loading...
  12. Chuck

    September 10, 2009
    at 5:46 AM

    Hey Milan, great plugin!

    I’m having problems with my results displaying the actual rating in the stars. It shows the stars greyed out, and ranks the pages correctly, but stars aren’t right. Same thing for the widget… text results work, but stars are greyed out.

    Here is link to example: http://www.coffeewithchuck.net/2009/09/los-angeles-best-coffee-shops/

    Thanks for any help!
    Chuck

    GD Star Rating
    loading...
    • Chuck

      September 10, 2009
      at 5:58 AM

      YES! After poking around, I’m answering my own question. I simply change %STARS% to %REVIEW_STARS% in the template. Yes, very very happy. Great plugin!

      GD Star Rating
      loading...
  13. Chuck

    September 10, 2009
    at 6:44 AM

    You’re going to kill me for multiple posts, but I’m wondering if there are any ELEMENTS available for Date? I’d love to completely replace my RECENT POSTS widget with RECENT RATINGS widget, but would like the post date on there. Is this currently possible?

    GD Star Rating
    loading...
    • MillaN

      September 11, 2009
      at 1:42 PM

      No, but I will add the tag with post date soon.

      GD Star Rating
      loading...
      • Chuck

        September 11, 2009
        at 5:53 PM

        Sweet!

        GD Star Rating
        loading...
  14. Rick Davies

    September 11, 2009
    at 11:25 AM

    Hi

    I am sure this problem has been discussed before, but despite much searching and effort, including by my web host (who specialise in wordpress) I am no closer to solving it

    I get the following text displayed under each post,…but no graphics (e.g. stars) at all:
    Rating: 0.0/10 (0 votes cast)
    Rating: 0 (from 0 votes)

    Wordpress is in http://www.mande.co.uk/blog and there are some pre-wordpress static files in http://www.mande.co.uk/

    I would pay £25 by Paypal to anyone who can solve this problem for me, and get the plugin working. I think it has potential, but it’s installation is costing me time

    GD Star Rating
    loading...
    • MillaN

      September 11, 2009
      at 1:38 PM

      I really don’t know how some people can miss the most obvious way to find the solution, and that is simple browsing of the website. If you open the Tutorials menu, you will find the SOLVING PROBLEMS and 4 posts in it. One of them explains what the problem can be in your case: http://www.gdstarrating.com/2009/02/03/human-factor-problems/. Your server access rights to some of the plugins files are set wrong (most likely the whole folder with the plugin is set wrong), and CSS and JS files fail to load, because they are not ordinary static file but dynamic created using PHP.

      I really should start deleting more comments, maybe then people will try to follow few basic rules about FREE support.

      GD Star Rating
      loading...
      • Rick Davies

        September 11, 2009
        at 7:15 PM

        I was not asking for FREE support, as it says above, I am willing to pay £25 for useful support,… from a patient person.

        I will check the server access rights, though I have no idea why in my case they should be wrong, when they were not changed by me at any stage.

        GD Star Rating
        loading...
        • Rick Davies

          September 11, 2009
          at 11:41 PM

          All the folder and sub-folders and files in this plugin have write and execute ticked. But the stars still dont appear. I have also reinstalled the software twice. But to no avail.

          My offer of £25 still stands, perhaps I should make it more visible on a wordpress.org forum…?

          GD Star Rating
          loading...
        • MillaN

          September 12, 2009
          at 12:30 AM

          All files should be 644 and folder 755. That is standard setting that is most commonly used. If that doesn’t help, you need to consult your hosting admin. And donations are always welcome.

          GD Star Rating
          loading...
  15. MillaN

    August 13, 2009
    at 4:28 PM

    Yes, I will add new functions in next version.

    GD Star Rating
    loading...
  16. Mike

    August 13, 2009
    at 6:25 PM

    Sweet, this plugin is in a class of its own.

    GD Star Rating
    loading...

Comments are closed.

Social Networks

Subscribe via Feedburner Flickr Images

Feedburner updatesFeedburner

Sign up to receive all latest news about GD Star Rating directly to your email.