ExpressionEngine Add-ons

Rating:Comment_Form template tag

The Rating:Comment_Form tag allows your site users and guests to submit and edit threaded comments to rating reviews on channel entries. It essentially adds one more layer of commenting on your site. This form would typically be displayed on a single entry page inside a Rating:Entries loop.

{exp:rating:comment_form} content {/exp:rating:comment_form}

Parameters

The following parameters are available for use:

admin_template=

admin_template="some_template"

This parameter is for specifying the admin notification template to be used for sending a notification email to an Admin. Used in conjunction with the notify parameter.

anonymous=

anonymous="no"

This parameter controls whether or not the comment form will accept submissions from Guests without the name and email fields filled in.

edit

edit="yes"

This parameter allows you to use your Rating Comment form in "edit" mode. With this enabled, Super Admins and authors can edit their rating comment submissions. Simply add this parameter in conjunction with the rating_comment_id parameter and users will be able to edit the ratings they submitted.

form:attribute=

form:class="your_class_name"

This parameter allows you to control any form attribute for the form in your template. Simply replace attribute with an attribute name such as id, name, class, etc, and specify a value for that attribute. You can specify this parameter multiple times to control as many attributes as necessary. This would normally be done to control your form with Javascript or style it with CSS.

notify=

notify="email@example.com|email2@example.com"

This parameter sends notification emails to the email address(es) specified when new comments are submitted. Used in conjunction with the admin_template parameter. Separate multiple email addresses with the pipe character.

owner_template=

owner_template="some_template"

This parameter is for specifying the author notification template to be used for sending a notification email to the Author of the entry when new ratings are submitted. When this parameter is used, it automatically sends email notifications to the author of the channel entry.

rating_id

rating_id="{segment_3}"

This parameter is required to display the comment form. 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.

rating_comment_id

rating_comment_id="{segment_3}"

This parameter is used in conjunction with the edit parameter and is required be able to allow users to edit their rating comment with the Rating Comment form. You can pull a rating comment ID from the URI, or if you need, to pass the rating comment ID through an embedded template.

require_membership

require_membership="yes"

This parameter lets you set whether or not you want users to be logged in members to submit comments. Specifying a value of yes means that a user has to be logged in to submit comments. Default is no (guests can submit comments as well).

return

return="template_group/template_name"

This parameter determines where to send users once they have submitted your form.

secure_action=

secure_action="yes"

This parameter allows you to set the action on the form to have https://. Used for securely processing forms with SSL.

secure_return=

secure_return="yes"

This parameter allows you to set the return on the form to have https://. Used for securely processing forms with SSL.

site_id

site_id="2"

If you're using MSM (Multiple Site Manager), be sure to specify this parameter so Rating comments are saved to the correct MSM Site.

status

status="oogabooga"

This parameter allows you to set the status of incoming commments. By default, all comments are set to open. If you wish to review comments first, set the status parameter to closed. To create custom statuses, simply specify any status name you want in this parameter, and it will be created and applied to the comment.

template

template="template_group/template_name"

This parameter is used to tell the Rating module which template to use to format messages returned by the module for successful and unsuccessful actions. You will most likely be using this parameter to enable AJAX functionality.

Two conditionals and one variable become available in the template that you refer to. {if success}{/if} will evaluate to true if the submission action is successful. {if failure}{/if} will evaluate to true if the submission fails for some reason. And {message} will return the message from the Rating module indicating the details of a successful or unsuccessful action.

user_template=

user_template="some_template"

This parameter is for specifying the user notification template to be used for sending a notification emails of followup comments to users that have submitted a rating, and subscribed to the entry by checking the notify_me checkbox.

output_json=

output_json="yes"

Using this parameter with a value of yes allows for AJAX requests to return errors and success mesages in JSON. Default is no.

ajax_request=

ajax_request="no"

Using this parameter with a value of no forces the form to do a standard redirect after a new entry is inserted, even when the request was made via AJAX.

Variables

All standard and custom member fields are available for use. Additionally, these are also available:

rating_comment

{rating_comment}

In edit mode, this variable will parse as the rating comment of the member that submitted the rating comment.

rating_comment_name

{rating_comment_name}

This variable will be replaced by the screen name of the logged in user or the name of a Guest that has opted to save their info for their next visit using the save_info form field.

rating_comment_email

{rating_comment_email}

This variable will be replaced by the email address of the logged in user or the email address of a Guest that has opted to save their info for their next visit using the save_info form field.

rating_comment_url

{rating_comment_url}

This variable will be replaced by the URL of the logged in user or the URL of a Guest that has opted to save their info for their next visit using the save_info form field.

rating_comment_location

{rating_comment_location}

This variable will be replaced by the Location of the logged in user or the Location of a Guest that has opted to save their info for their next visit using the save_info form field.

rating_comment_captcha

{rating_comment_captcha}

This variable will be replaced by the CAPTCHA image generated by the system. It will only appear for guests if you have enabled Captcha's in the Rating module CP, and will only appear for logged in members if you've also set the Require CAPTCHA while logged in? preference in EE CAPTCHA Preferences to Yes. Used in conjunction with captcha form field and rating_comment_captcha conditional.

Conditionals

The following conditionals are available for use:

rating_comment_captcha

{if rating_comment_captcha}{/if}

This conditional is available to show/hide your CAPTCHA image based on whether or not it's required. It will only appear for guests if you have enabled CAPTCHA's in the Rating module CP, and will only appear for logged in members if you've also set the Require CAPTCHA while logged in? preference in EE CAPTCHA Preferences to Yes. Used in conjunction with captcha form field and rating_comment_captcha variable.

rating_comment_no_results

{if rating_comment_no_results}{/if}

This conditional will display its contents if the current user does not have sufficient privileges to submit rating comments.

Form Fields

The following form fields are available for use:

captcha

<input type="text" name="captcha" />

This form field allows your users to submit the contents of the CAPTCHA image. Used in conjunction with rating_comment_captcha variable and rating_comment_captcha conditional.

comment

<textarea name="comment"></textarea>

This field is required and is used to collect the users comment.

email

<input type="text" name="email" />

This form field is intended for use with Guest submissions, and will collect the email address of the Guest submitting a comment. A logged in members' email address will be recorded automatically without any need of specifying this field. This field is required when a user is not logged in and the Require email address for Guests? setting in the Rating Preferences tab is set to Yes.

location

<input type="text" name="location" />

This form field will collect the location of the Guest submitting a comment. Can be later parsed out in the Rating:Entries loop by using the rating_location variable.

name

<input type="text" name="name" />

This form field will collect the name of the Guest submitting a comment. A logged in members' screen name will be recorded automatically without any need of specifying this field. This field is required when a user is not logged in unless you've specified the anonymous parameter (set to yes).

save_info

<label for="save_info">
    <input type="checkbox" name="save_info" id="save_info" value="y" {save_info} />
    Remember my contact info for next time? (Guests)
</label>

This form field allows your Guests to save their contact info for their next visits to your site. All fields such as name, email, url and location will pre-populate with the Guest's information for next time, providing you include the {name}, {email}, {url} and {location} variables as values for the form fields. A {save_info} variable also becomes available and parses as checked="checked" to automatically select the save_info checkbox for next time as well.

notify_me

<label for="notify_me">
    <input type="checkbox" name="notify_me" id="notify_me" value="y" {notify_me} />
    Notify me of future Ratings?
</label>

This form field allows your users to subscribe to a rating entry to be notified of future comments submitted by others for that particular rating. A {notify_me} variable also becomes available an parses as checked="checked" to automatically select the notify_me checkbox for next time as well. Be sure to specify the user_template parameter to designate a notification template for this feature.

url

<input type="text" name="url" />

This form field will collect the URL of the Guest submitting a comment.

Examples

Integrated with the Rating:Entries and Rating:Comments 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>
                {rating_comment_name} 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}