If you are using in projects LikeDislike, and want to thank the author.
Even though LikeDislike is designed to be easy to install, you should be comfortable with the following operations:
LikeDislike requires a few things in order to work.
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
In a convenient location site template you need to insert a snippet
[[likeCssjs]]that connects CSS and JS files needed to run LikeDislike.
&jsConnect=`true`
, and the call should look like this
[[likeCssjs? &jsConnect=`true`]]
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.
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 numberBy 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.
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]].
The uniqueness of the object in order to vote consists of three parts.
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. |
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`]]
Name | Demonstration | Options |
---|---|---|
buttons |
code snippet: [[!LikeDislike? &tpl=`buttons` &name=`Demo buttons`]] |
|
mini_poll |
code snippet: [[!LikeDislike? &tpl=`mini_poll` &name=`Demo mini_poll`]] |
|
mini_likedislik |
code snippet: [[!LikeDislike? &tpl=`mini_likedislik` &name=`Demo mini_likedislik`]] |
|
likedislik_up |
code snippet: [[!LikeDislike? &tpl=`likedislik_up` &name=`Demo likedislik_up`]] |
|
likedislik_up_down |
code snippet: [[!LikeDislike? &tpl=`likedislik_up_down` &name=`Demo likedislik_up_down`]] |
|
up_down |
code snippet: [[!LikeDislike? &tpl=`up_down` &name=`Demo up_down`]] |
|
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.closed like.user_voted like.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 |
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}%`]]
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.
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 |
&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 |
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:
|
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:
|
[[!LikeDislike? &name=`[[*pagetitle]]` &rating=`type=1`]]
[[!LikeDislike? &name=`Test2` &rating=`type=1,tv=myLike,output=votes_up`]]
[[!LikeDislike? &name=`Test3` &rating=`type=2,column=longtitle,output=votes_pct_up`]]
[[!LikeDislike? &name=`[[*pagetitle]]3` &rating=`type=2,column=properties`]]