ExpressionEngine Add-ons

Rating:Delete template tag

The Rating:Delete function allows you to delete specific rating reviews or all rating reviews for an entry, via the front end. Simply create a link to a template with the Rating:Delete code, and supply the appropriate criteria in the URI. The Delete function respects the member group Deleting permissions in the Preferences tab of the Rating module CP.

{exp:rating:delete} content {/exp:rating:delete}

Parameters

The following parameters are available for use:

entry_id=

entry_id="{segment_4}"

This parameter should be specified when you wish to delete all ratings for a particular entry. You would usually grab the entry ID of the entry through a segment in the URL.

rating_id=

rating_id="{segment_4}"

This parameter should be specified when you wish to a specific rating on an entry. You would usually grab the rating ID of the entry through a segment in the URL.

rating_comment_id=

rating_comment_id="{segment_4}"

This parameter should be specified when you wish to delete a specific rating comment for a specific Rating entry. You would usually grab the rating comment ID of the entry through a segment in the URL. You must be the author of the comment or a Super Admin to be able to delete the comment.

Variables

The following variables are available for use:

message

{message}

This variable will output the appropriate message once a rating or entry's ratings are deleted, or not.

Conditionals

The following conditionals are available for use:

success

{if success}{/if}

This conditional will output its contents if the deletion is successful.

Examples

Below is a “smart” code example which can handle both single rating deletion, and all ratings of an entry deletion. It assumes you will have the entry ID or rating ID in the 4th segment of the URL, and that you will specify a type of rating or entry in the 3rd segment of the URL for it to determine which action to take:

{if segment_4}
    {if segment_3 == "rating"}
        <!-- check if we're deleting a Rating entry -->
        {exp:rating:delete rating_id="{segment_4}"}
            <p>{if success}Woohoo!{if:else}I failed: {message}{/if}</p>
        {/exp:rating:delete}
    {if:elseif segment_3 == "entry"}
        <!-- check if we're deleting ALL ratings for an entry -->
        {exp:rating:delete entry_id="{segment_4}"}
            <p>{if success}Woohoo!{if:else}I failed: {message}{/if}</p>
        {/exp:rating:delete}
    {if:elseif segment_3 == "rating_comment"}
        <!-- check if we're deleting a Rating comment for a Rating entry -->
        {exp:rating:delete rating_comment_id="{segment_4}"}
            <p>{if success}Woohoo!{if:else}I failed: {message}{/if}</p>
        {/exp:rating:delete}
    {/if}
{if:else}
    <!-- segment 4 does not exist -->
    <p>No rating or entry was specified.</p>
{/if}

You would link to this template from the Ratings templates like this:

Inserted in Channel:Entries loop:

<a href="/rating/delete/entry/{entry_id}/">Delete ALL Ratings for this Entry</a>

Inserted in Rating:Entries loop:

<a href="/rating/delete/rating/{rating_id}/">Delete this Rating</a>

Inserted in Rating:Comments loop:

<a href="/rating/delete/rating_comment/{rating_comment_id}/">Delete this Rating comment</a>