We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40024
    • 72 Posts
    Hi, what i would like to know is whether a functionality such as the following exists,and if not how could it be implemented:
    I want the rating score to appear. Like, let's say that an image has a total score of 4.3 rating.,I would like to know how this 4.3 score can be retrieved and displayed elsewhere. Is this anyway possible?

    [EDIT]
    Ok,i have somehow managed to work this out a bit by doing this:
    1)Create a snippet called DisplayRating.
    2)Paste this code inside:
    <?php
    $query = $modx->db->select("rating", $modx->getFullTableName('atrating_GRPNAME'),"id>='2' AND rating_id='".$modx->documentObject['pagetitle']. "'");
       $rating = $modx->db->getValue($query);
    
    return $rating/10;
    ?>


    3)Change the grpName to match the name you have defined in the anything rating call.

    4)Call the snippet like this wherever you want the rating to display: [!DisplayRating!]

    A note to remember is that the atrId from anything rating's rated item call, needs to be [*pagetitle*]. e.g.
    [!AnythingRating? &atrGrp=`grpName` &atrId=`[*pagetitle*]`!]
    . If u don't want the pagetitle but another part of a resource document then just remember to update both the anythingrating snippet call AND the snippet DisplayRating.
    I am not sure my snippet is well-written but worked a little bit for me.

    Now what i want to know is how would i get this rating value to display with a ditto call? [ed. note: dinpapa last edited this post 12 years, 5 months ago.]