|
Today, I worked on getting the blog section of this very site, sankuru.biz, up and running. I did not feel the need to install an external blogging system. Joomla 1.5's native publishing system already has a sufficiently large number of sometimes confusing options, that I could easily resist the urge to install an additional system with even more whistles and bells. A good blogging system, however, needs some kind of commenting system. So, I went to the Joomla extension site, in order to look for a commenting add-on for my new blog. Forward looking, I thought it was preferable to install an native 1.5 commenting system instead of one written for Joomla 1.0, which would have to run in legacy mode. The first open-source -- and therefore modifiable -- commenting system I came across, was the DISQUS comment system for Joomla! - by JoomlaWorks. Now, DISQUS is not really a truly fully-fledged comment plugin, as it manages and stores comments on the DISQUS server, so it is rather a "cloud computing"-style of setup. Cloud computing does have its advantages. One advantage is that you do not need to worry about upgrading and fixing bugs or otherwise managing things by yourself. The associated disadvantage, is, of course, that you may lose some control over how the system works. But then again, there seems to be a community growing around DISQUS commenting forums, and that could be interesting too. Based on these trade-offs, I decided to go ahead with it, and try it out. I installed the DISQUS plugin on this site, and indeed, at first glance it worked absolutely fine. I had to deal with one issue, however. The plugin enables commenting on all articles. There are a few articles in this site, that are just meant to publish information, such a "Contact", where I don't see the use in enabling a commenting system. The DISQUS plugin does not offer any configurable options to exclude particular sections, categories, or articles. So, I instantly felt the urge to "do something about it" and had a close look at the source code for the plugin. The master script file for the DISQUS plugin resides in the plugins/content/jw_disqus.php file. The script registers two functions in the Joomla content interception tables: $mainframe->registerEvent( 'onBeforeDisplayContent', 'plgJWDisqus_onBeforeDisplayContent'); $mainframe->registerEvent( 'onAfterDisplayContent', 'plgJWDisqus_onAfterDisplayContent'); Before displaying the article's content, the plugin's functions write the View comments link. After displaying the article, the corresponding function writes the form that allows site visitors to write a comment. So, I proceeded by adding the following function, in order to exclude a list of articles from the commenting system: function noCommentsForThisArticle($id) { $disabled=array(1,2,4,6,7,14,15); if(in_array($id,$disabled)) return true; else return false; } Then, I made sure, that the functions registered for the events, call this function first, before entering the actual code: function plgJWDisqus_onBeforeDisplayContent( &$row, &$params, $limitstart ){ if (noCommentsForThisArticle($row->id)) return; global $mainframe; ...} function plgJWDisqus_onAfterDisplayContent( &$row, &$params, $limitstart ){ if (noCommentsForThisArticle($row->id)) return; global $mainframe; ...} Of course, this is just a hack. The proper way would consist in expanding the parameters for the plugin with excluded/included sections, categories, and articles.
|