Expression Engine 2 Like add-on

Costs: Free!
Type of add-on: Module
Version: 1.0.0

Likes already received: 187

Purpose

The Like plugin allows you to add a Like-button to any Expression Engine channel entry. The generated Like button can be easily customized and it directly connects to the particular channel entry to update its score field. Because of this behaviour it is possible to easily generate overviews of entries that have been ordered by their individual scores.

The plugin can be used in two ways: members only or by allowing entries to be liked based on IP checking. Different channels can have different ways of allowing users to like items.

You can see the plugin at work at the top of this page. Feel free to click it of course!

Documentation

Downloading

Click here to download this add-on

Installation

Unzip the downloaded zipfile and upload the like directory to:
/system/expressionengine/third_party

Navigate to the Add-Ons > Modules page in your control panel and install the Like module.

Usage

Before you start using the Like add-on, make sure one of your channel's fields is of the - new to EE2 - integer type. This field will be used to store an item's score. If you fail to supply a proper integer fieldname when using the Like add-on, you will receive an error message telling you so.

An example:

{exp:channel:entries channel="rss_feeds" limit="10" orderby="item_score" sort="desc"}
{title} ({item_score})
{if logged_in}
	{exp:like 
		method="member"
		entry_id="{entry_id}"
		score_field="item_score"
		like_image_path="/images/like.png"
		liked_image_path="/images/liked.jpg"
		extra_parameters="style='width: 16px; height: 16px; margin: 0px;'"
		form_class="formclass"}
{/if}
{/exp:channel:entries}

In the above example a few things are shown. The channel:entries tag uses the item_score field to determine its order. This item_score has been defined as the integer type mentioned earlier. Everytime someone likes an entry, the score of this item is updated with 1. This allows you to display an item's score anywhere you want or - as in this example - even use it as a key to order the list.

Parameters

You can use the following parameters:

method
The method used to like a channel entry. Can be set to member or ip.

entry_id
The entry_id that this Like-button will be connected to.

score_field
This is the name of the field that will be updated as soon as somebody likes an item. This field should be defined as an integer or else the Like add-on will output an error message.

like_image_path
The URL to the image that will be shown. This is the version where somebody has not yet liked an entry.

liked_image_path
The URL to the image that will be shown after somebody has already liked an item.

extra_parameters
Optional extra parameters to be added to the image/input tag.

form_class
Optional CSS class specification for the form that is generated.

return_url
Optional return url to redirect user to when he or she has liked an entry. The return_url variable was added to allow users to be redirected to a thank you page or to make sure Expression Engine shows updated scores correctly immediately after submittal. If you let the Like add-on perform its default behaviour, you will be redirected to the same page that had the Like-button on it, but Expression Engine will usually not list the updated score value properly. The return_url parameter allows a work-around for this.