Note! This is the first beta version. The source code can be viewed on github.com/artdevue/LikeDislike. Errors that you have, while using the Like Dislike, you can leave on this link

Before you install

Technical skills

Even though LikeDislike is designed to be easy to install, you should be comfortable with the following operations:

Office of the panel
Confident user administration panel MODX Revolution.
Chunk and Snippets
Know the basics of what Chunk and that such Snippets

System requirements

LikeDislike requires a few things in order to work.

Version of the system
You must have a version of MODX Revolution 2.2.1 or later version.
JQuery
Version of the JQuery 1.4 or higher

Uploading

Using the control panel MODX, go to Package Management packages in the search bar, type "LikeDislike", download and install.

The source code is located on github.com

Including LikeDislike in your website

In a convenient location site template you need to insert a snippet

[[likeCssjs]]
that connects CSS and JS files needed to run LikeDislike.
Note! If you have a web site is not connected JQuery, then the call must specify the &jsConnect=`true`, and the call should look like this
[[likeCssjs? &jsConnect=`true`]]

Basic Configuration

Before you start using LikeDislike, you can customize it to fit your work priorities. You can configure Cookies, IP and user id

The main settings are located in LikeDislike System Settings, in the section "likedislike".

All tips are described in the comments for each configuration.

Note! , Lifetime of the cookie likedislike.cookieLifetime, is the sample count. To properly preserved for one year cookie, multiply the numbers in the parameter likedislike.cookieLifetime (should be able to 31536000) and write one number

Admin panel

By selecting the top menu under "Components" - LikeDislike, you are in control LikeDislike.

You can keep track of your objects, delete them, close the vote. Added to the blocked IP addresses of users who are not eligible to vote.

The basics

You can create LikeDislike click anywhere on the page. To do this, add the snippet call:

[[!LikeDislike? &name=`ITEM_NAME`]]

The item name (in bold) may be omitted if you visit a call LikeDislike, because the default name equally [[*pagetitle]].

Remember! , that the element name must be unique on a single resource or exclusion.
Call LikeDislike should NOT CACHE

Hash name

The uniqueness of the object in order to vote consists of three parts.

Parameters:

Properties By default Description
name [[*pagetitle]] Name of your facility in order to vote, the default is the title of the resource. By title, you will easily navigate the control module administration LikeDislike
likeId [[*id]] We should not be confused with id LikeDislike. By default, the id of the resource on which the call. This option gives its uniqueness for example by using in the comments
category [[*class_key]] By default, this class of resource - modDocument. You can use objects to group your vote on the site, as in a control module administration LikeDislike, is a sample for this category.
It is important that these three parameters are not matched in other resources!.
Exception
If you want to show the same result of the vote in the different resources or different templates to display in the output result, then you should consider that these three parameters sovpodali.

Choosing a template

When an object is created, the template is used by default ("mini_likedislik"). You can choose a different default template if you wish. Just change the parameter "likedislike.defaultTemplate" at your option system Settings MODX.

To change the template for an object, you simply need to specify tpl in the call to the snippet, for example:

[[!LikeDislike? &tpl=`likedislik_up`]]

List of all templates

Name Demonstration Options
buttons
254 out of 302 people like this. And you?

code snippet:
[[!LikeDislike? &tpl=`buttons` &name=`Demo buttons`]]
  • up: text for the “up” button (default: 'Yes')
  • down: text for the “down” button (default: 'No')
  • question: question displayed after the result (default: 'And you?')
mini_poll

code snippet:
[[!LikeDislike? &tpl=`mini_poll` &name=`Demo mini_poll`]]
  • up: text for the “up” button (default: 'Yes')
  • down: text for the “down” button (default: 'No')
  • color_up: color for the “up” result graph (default: '#bbb')
  • color_down: color for the “down” result graph (default: '#bbb')
mini_likedislik
+106

code snippet:
[[!LikeDislike? &tpl=`mini_likedislik` &name=`Demo mini_likedislik`]]
  • align: 'left' or 'right' (default: 'left')
likedislik_up
455 like voting
is closed
thanks
for your vote

code snippet:
[[!LikeDislike? &tpl=`likedislik_up` &name=`Demo likedislik_up`]]
  • align: 'left', 'right' or 'center' (default: 'center')
likedislik_up_down
+258 -130 voting
is closed
thanks
for your vote

code snippet:
[[!LikeDislike? &tpl=`likedislik_up_down` &name=`Demo likedislik_up_down`]]
  • align: 'left', 'right' or 'center' (default: 'center')
up_down
+136

code snippet:
[[!LikeDislike? &tpl=`up_down` &name=`Demo up_down`]]
  • align: 'left', 'right' or 'center' (default: 'center')

Custom templates

It is important you should have an average level of knowledge of HTML and JQuery!.

You can specify your newly created template is oriented and the logic of keeping the template, templates, examples can look at github.com or look at the server in a directory - the folder path core/ components/likedislike/elements/chunks

Chunk takes the following parameters:

Parameter Description
like.id (numeric) id of your item in the database, not to be confused with the&likeId
like.category (string) Category of your item to a vote, by default, this class of resource - modDocument. You can use items to group your vote on the site, as in a control module administration LikeDislike, is a sample for this category.
like.name (string) Name of your item in order to vote, the default is the title of the resource. By title, you will easily navigate the control module administration LikeDislike
like.closed (numeric) 0 - open voting, 1 - voting closed
like.date (strftime) Date of creating an item of voting
like.votes_up (numeric) The number of votes - Up
like.votes_down (numeric) The number of votes - Down
like.votes_total (numeric) Total number of votes (Up + Down)
like.votes_balance (numeric) The balance of voting (Up - Down)
like.votes_pct_up (string) Percentage of vote, Up
like.votes_pct_down (string) Percentage of vote, Down
like.user_voted (bool) TRUE - the user has already voted, FALSE - the user has not voted
like.color_up (string) color for the “up” result graph (default: '#bbb')
like.color_down (string) color for the “down” result graph (default: '#bbb')
like.tpl (string) The name of a template for your vote of item
like.up (string) text for the “up” button (default: 'Yes')
like.down (string) text for the “down” button (default: 'No')
like.disabled (string) If the voting is closed - then disabled="disabled", if not - then empty
like.class (string) The class, which is formed of parameter like.closedlike.user_votedlike.disabled
like.round (numeric) The number of decimal places. If you want to show the result of the withdrawal up to a decimal. By default, the - 0
like.question (string) Question displayed after the result (default: 'And you?')
like.format (string) Output format is the default for each pattern a result of the withdrawal, which can be changed in the class LikeDiskike, in the future, I will bring to the setting.
like.result_up (string) The vote of up, processed by the output format
like.result_down (string) The vote of down, processed by the output format

Formatting the results

LikeDislike allows you to customize the result display for each item. Template mini_likedislik, for example, shows the balance of votes on default. Template mini_poll shows the percentage of votes for / against. Each template has a default format.

Here's how to set up a custom format for a:

[[!LikeDislike? &tpl=`likedislik_up` &format=`{+PCT_UP}%`]]

Format string syntax

A format string is just a short piece of text with some special codes in it. Each code, wrapped in braces, will be replaced with its applicable value. Here's the list of all the available codes:

Format Description
{UP} The number of up votes
{DOWN} The number of down votes
{PCT_UP} The percentage of votes that is up
{PCT_DOWN} The percentage of votes that is down
{TOTAL} The total number of votes (up + down)
{BALANCE} The vote balance (up - down)

Text that is placed outside of the braces is considered literal text, except for double vertical bars '||' which split up the format string into multiple areas. This is needed for templates like mini_poll or likedislik_up_down.

Inside the braces you can include a plus or minus sign at the front, e.g. {+UP} or {-DOWN}. The plus sign will then be prepended to positive values, the minus to negative values. No sign is shown in front of 0-values.

If you want to show the result of the withdrawal up to a decimal, you can do this by adding an item to each voting option round, indicating the number - the number of digits after the decimal point, or set in the settings of global significance.


Examples

For an item with 10 Up votes and 5 Down votes, here's what the following format strings would produce:

&format &round Result
{UP} 10
{DOWN} 5
{+BALANCE} +5
{UP} out of {TOTAL} people voted “yes” 10 out of 15 people voted “yes”
Percentage of “no” votes: {PCT_DOWN}% Percentage of “no” votes: 33%
{-PCT_DOWN} -33%
{-PCT_DOWN} 1 -33,3%
{-PCT_DOWN} 2 -33,33%
Score: {PCT_UP}/100 1 Score: 66.7/100

System Events OnlikeDislikeSave

Note! System Events OnlikeDislikeSave run if the parameter in the snippet &rating!.

The event started at the time of voting. ie write yes or no.

Take parameters:

Parameter Description
id (numeric) id of your item in the database, not to be confused with the &likeId
category (string) Category of your item to a vote, by default, this class of resource - modDocument.
name (string) Name of your item in order to vote
closed (numeric) 0 - open voting, 1 - voting closed
date (strftime) Date of creating an item of voting
votes_up (numeric) The number of votes - Up
votes_down (numeric) The number of votes - Down
votes_total (numeric) Total number of votes (Up + Down)
votes_balance (numeric) The balance of voting (Up - Down)
votes_pct_up (string) Percentage of vote, Up
votes_pct_down (string) Percentage of vote, Down
tvRat (string) TV name
column (string) field name to write to the resource
outputRat (string) property to vote
typeRat (numeric) record type ('votes_up','votes_down','votes_total','votes_balance','votes_pct_up','votes_pct_down')
resRat (numeric) id resource

Output in TV or resource

To display the results in the resource box or the TV to use the &rating . All of the property for &rating listed separated by commas.

Take parameters:

Parameter Description

for type=1 and type=2

output record type, by default votes_balance

available:

votes_up
The number of votes - Up
votes_down
The number of votes - Down
votes_total
Total number of votes (Up + Down)
votes_balance
The balance of voting (Up - Down)
votes_pct_up
Percentage of vote, Up
votes_pct_down
Percentage of vote, Down

for type=1

tv the name of your TV setting, the default likeDislike
Note! Be sure to TV option with parameter input - hidden.

for type=2

column field name to write to the resource, the default - description

available:

longtitle
description
introtext
properties
in this field does not have to specify an output, because all parameters are recorded output as a json array.
Note! If you store your data in the column properties, your data is not erased, but simply supplemented by new parameters LikeDislike. Field properties are not sufficient to search and sort your search criteria, this field is used to store information that can be displayed on the website without having to call and joins to other tables.

Examples:

code:
Record the balance in TV named LikeDislike
[[!LikeDislike? &name=`[[*pagetitle]]&rating=`type=1`]] 
code:
Record the number of votes - Yes TV named myLike
 [[!LikeDislike? &name=`Test2` &rating=`type=1,tv=myLike,output=votes_up`]]
code:
Record the percentage of the vote Yes in the longtitle your resource
 [[!LikeDislike? &name=`Test3` &rating=`type=2,column=longtitle,output=votes_pct_up`]] 
code:
Add to json array all type parameters - output
[[!LikeDislike? &name=`[[*pagetitle]]3&rating=`type=2,column=properties`]]

©2012 LikeDislike

Processing Time: 0.0477 s

Powered by MODX
ArtDeVueDeveloped by