Rating Documentation

Rating:Comments template tag

The Rating:Comments loop displays all comments that where submitted to a given rating entry (for a channel entry). When used in conjunction with the Rating:Entries tag, it will look like threaded comments. This loop would typically be used on a single entry page inside a Rating:Entries tag, alongside a Rating:Comment_Form tag.

{exp:rating:comments} content {/exp:rating:comments}

Parameters

The following parameters are available for use:

limit=

limit="20"

This parameter allows you to limit the number of comments in your results.

orderby=

orderby="date"

This parameter allows you to control the order of your comments. You can specify date, or random.

paginate=

paginate="both"

This parameter allows you to control where the pagination will display. Options are top, bottom, or both. Used in conjunction with the rating_comment_paginate variable pair.

rating_id=

rating_id="{segment_3}"

This parameter is required and necessary to display comments for a given rating review. You can pull a rating ID from the Rating:Entries tag, from the URI, or if you need, to pass the rating ID through an embedded template.

sort=

sort="asc"

This parameter allows you to indicate which direction to sort your comments. Options are ascending (asc) or descending (desc).

status=

status="open"

This parameter allows you to filter ratings by their status. By default, it will only show ratings that are open. To specify multiple statuses, use the pipe character.

Variables

Most of the standard and custom member field variables available here. Additionally, these exist as well:

rating_comment_author_id

{rating_comment_author_id}

This variable displays the member ID of the user that submitted the comment.

rating_comment_avatar

{if rating_comment_avatar}
    <img
        src="{rating_comment_avatar_url}"
        height="{rating_comment_avatar_height}"
        width="{rating_comment_avatar_width}"
    />
{/if}

This variable is available as a conditional, and can be used to display a member's avatar with other related variables, such as rating_comment_avatar_url, rating_comment_avatar_height, and rating_comment_avatar_width.

rating_comment_count

{rating_comment_count}

This variable displays the position number of the comment in the list for a given page.

rating_comment_email

{rating_comment_email}

This variable displays the email address of the user that submitted the comment.

rating_comment_name

{rating_comment_name}

This variable displays the screen name of the user that submitted the comment, or the name entered by a guest in the name field in the comment form.

rating_comment_screen_name

{rating_comment_screen_name}

This variable displays the screen name of the logged in user that submitted the comment. For parsing of names for guests, refer to the rating_comment_name variable. This variable can also be used as a conditional to check if the comment submitted was a logged in user or a guest.

rating_comment_group_id

{rating_comment_group_id}

This variable displays the member group ID of the user that submitted the comment.

rating_comment_photo

{if rating_comment_photo}
    <img
        src="{rating_comment_photo_url}"
        height="{rating_comment_photo_height}"
        width="{rating_comment_photo_width}"
    />
{/if}

This variable is available as a conditional, and can be used to display a member's photo with other related variables, such as rating_comment_photo_url, rating_comment_photo_height, and rating_comment_photo_width.

rating_comment

{rating_comment}

This variable will parse out the comment that was submitted.

rating_comment_location

{rating_comment_location}

This variable will parse out the value the of the submitters location. If the comment was submitted by a member it will parse the value in the members location member field. If the comment was submitted by a guest, it will parse out the value the guest filled in the location form field, if any.

rating_comment_date

{rating_comment_date format="%F %j, %Y at %g:%i %a"}

This variable allows you to display the date of the comment submission. Usual EE time formatting is also available.

rating_comment_switch

{rating_comment_switch="blue|red"}

This variable will output alternately by each of the two values you provide. You would typically use this for styling your results with CSS.

rating_comment_total_results

{rating_comment_total_results}

This variable displays the total number of results in the list for a given page. You would typically use this in a conditional statement.

rating_comment_absolute_results

{rating_comment_absolute_results}

This variable displays the total number of results in the list across all pages (if pagination is used). You would typically use this in a conditional statement.

Variable Pairs

The following variable pairs are available for use:

rating_comment_paginate

{rating_comment_paginate}
    <li>
        Page {rating_comment_current_page} of
        {rating_comment_total_pages} pages &nbsp;
        {rating_comment_pagination_links}
    </li>
{/rating_comment_paginate}

OR

{rating_comment_paginate}
<ul class="pagination">
    {rating_comment_pagination_links}
        {first_page}
            <li><a href="{pagination_url}">First</a></li>
        {/first_page}
        {previous_page}
            <li><a href="{pagination_url}">&laquo; Previous</a></li>
        {/previous_page}
        {page}
            <li{if current_page} class="active"{/if}><a href="{pagination_url}">{pagination_page_number}</a></li>
        {/page}
        {next_page}
            <li><a href="{pagination_url}">Next &raquo;</a></li>
        {/next_page}
        {last_page}
            <li><a href="{pagination_url}">Last</a></li>
        {/last_page}
    {/rating_comment_pagination_links}
</ul>
{/rating_comment_paginate}

Pagination is available for this tag and works just like regular EE pagination, but each variable/variable pair is prepended with ratingcomment (except for any variables and variable pairs inside of the rating_comment_pagination_links variable pair). Used in conjunction with the paginate parameter.

Conditionals

Most of the variables above in addition to standard and custom member fields are available as conditionals. Additionally, these exist as well:

rating_comment_no_results

{if rating_comment_no_results}
    Sorry, no comments have been submitted for this rating yet.
{/if}

This conditional evaluates to true and displays it's contents when there are no results found for this tag.

Examples

Integrated with the Rating:Entries and Rating:Comment_Form tags, your code might look something like this:

{exp:channel:entries require_entry="yes"}
    <h2>{title}</h2>
    <p>{body}</p>
{/exp:channel:entries}

<h3>Ratings for this Entry:</h3>
{exp:rating:entries
    limit="10"
}

    {if screen_name}
        <p><a href="{path='user/profile'}/{member_id}/">
            {screen_name}</a></p>
        {if avatar}
            <img src="{avatar_url}"
                width="{avatar_width}" height="{avatar_height}" />
        {/if}
    {if:else}
        <p>{name} (Guest)</p>
    {/if}
        <p>{stars}{rating}{/stars}</p>
        <p>Submitted on {rating_date format="%F %n, %Y at %g:%i %a"}</p>
        <p>{review}</p>

<!-- Comments begin -->

        <h3>Comments for this Rating:</h3>
        <ul>
        {exp:rating:comments
            rating_id="{rating_id}"
            limit="3"
            orderby="date" sort="desc"
        }
            <li>
                <a href="{path='member/profile'}/{rating_comments_author_id}/">{rating_comment_name}</a> on
                {rating_comment_date format="%F %j, %Y at %g:%i %a"}<br />
                <i>{rating_comment}</i>
            {if rating_comment_no_results}
                This rating has not been commented on yet.
            {/if}
            </li>
        {/exp:rating:comments}
        </ul>

<!-- Comments end -->

<!-- Comment Form begin -->

        {exp:rating:comment_form
            rating_id="{rating_id}"
            return="rating/thanks"
        }
            <h3>Comment on this Review</h3>

            <!-- only show this to guests -->
            {if logged_out}
                <p>
                    <label for="name">Name</label>
                    <input type="text" name="name" id="name" value="{name}" />
                </p>
                <p>
                    <label for="email">Email</label>
                    <input type="text" name="email" id="email" value="{email}" />
                </p>
                <p>
                    <label for="save_info">
                        <input type="checkbox" name="save_info" id="save_info" value="y" {save_info} />
                        Remember my contact info for next time?
                    </label>
                </p>
            {/if}
            <p>
                <label for="comment">Your Comment</label>
                <textarea name="comment" id="comment"></textarea>
            </p>
            <p>
                <input type="submit" name="submit" value="Submit" />
            </p>
            {if rating_comment_no_results}
                <p>
                    Sorry, you currently do not have sufficient privileges to submit rating comments.
                </p>
            {/if}

        {/exp:rating:comment_form}

<!-- Comment Form end -->       

    {if rating_no_results}
        <p>Sorry, no ratings have been submitted for this entry yet.</p>
    {/if}

{/exp:rating:entries}

Support

Having problems setting up and/or using Rating? Support is offered from 10am to 4pm EST weekdays. Send us an email at help@eeharbor.com and we will respond as quickly as we can.