logo ajaxSo, I want to implement a simple like/dislike plugin on our website for this new blog section. Just to get some idea if people follow and like (or dislike) individual blog-articles.

And before I start to reinvent a plugin I searched the Joomla! Extension Directory for some easy-to-use plugins. And there it is; the Egolt Like plugin from Soheil Novinfard. Although the plugin isn't worked on or supported anymore, it should do the 'trick'. At least, that was what I thought.

First I started testing in our local web-environment (ofcourse) and had to made some layout adjustments to the included CSS sets/icons to let the plugin better integrate with our website. After this some jQuery code was put in to move the like/dislike buttons in the "Created date" description list (<dl>).
So after a few hours editting, changing, coloring and adding code everything seems to work well. The buttons can be clicked, a nice animated loader is shown and the counter works perfectly. Time to put everything online!

To be sure everything looked good I've created a test blog category and article to be viewed by administrators only. The article loaded fine, the buttons are shown at the correct place and with the correct selected theme. Let's click the "Like  button, the animated loader is shown and ... eh... and... eh... what is going on? The animated loader is still showing ... but it should disappear after a few seconds to show the increased Liked counter.

Well, a few things must be checked: test the plugin again in our local web-environment: check! All works fine. Check the plugin parameters on our live site: check! They are exactly the same as in our test site. Let me just reinstall the plugin once more: check! That should do the trick. Sadly, no, that wasn't it. No matter what I do the loader image keeps rotating in the button and no counter is refreshed :-(
Wait! Let's compare the plugin files from our live site and the test site; maybe the installation package (XML manifest)  isn't working correctly. Hmmm, no luck either.htaccess

Think, think, think (pulling my hair out), what am I missing here? I checked every file, every setting and finally it hit me! In the test web-environment we have one file renamed, the .htaccess file, to disable it's functionality. Let's rename it back and see what happends.
Bingo! Now our local environment shows the same issue and then the solution sinks in: the Egolt Like plugin uses an AJAX call when hitting the Like/Dislike buttons. Clicking a button should show the animated loader, adds +1 to the already known votes and shows the sum of the votes without refreshing the webpage (that's what AJAX will do). But the .htaccess is blocking direct access to this file so the AJAX call is never run.

The solution to this AJAX struggle is simple; I've added the file from the plugin folder - which is responsible for the AJAX calls - to the .htaccess file so it can be accessed directly by the site. And now all works fine! Wanna try? Click the Like button at the right corner of this blog article :-)