- Add like.php to your
site/templates
folder - Create a new invisible like folder in
content/blog
- Place a
like.txt
incontent/blog
It's enough to puttitle: Like Updater
or something like that as content in there.
Go to http://yourdomain.com/blog/like
. This will invoke the Like Counter Updater. Since no parameter has been passed, you will get back an error.
{"status":"error","msg":"The post could not be found"}
Pass an UID of a blog article like this:
http://yourdomain.com/blog/like/post:my-awesome-post
If the article has been found, the like counter will increase and add a Likes field to your article's text file. On each reuquest, the like counter will increase again.
The response will look like:
{"status":"success","msg":"The likes have been updated","likes":5}
Here's a simple example how to call the like counter via ajax (jquery):
$.getJSON('/blog/like/post:my-awesome-article', function(r) {
if(r == undefined || r.status == 'error') {
return alert('Likes could not be updated');
} else {
return alert('Likes have been updated. New Likes count: ' + r.likes);
}
});