Extension:AjaxComments

MediaWiki extensions manual
AjaxComments
Release status: stable
Implementation User interface
Description Replace Talk page functionality with comments at the bottom of the page.
Author(s)
Latest version 2.9.0
MediaWiki
License GNU General Public License 2.0 or later
Download
  • $AjaxCommentsLikeDislike
  • $AjaxCommentsLikeDislike
  • $AjaxCommentsPollServer
  • $AjaxCommentsEmailNotify
  • $AjaxCommentsAdmins

The AjaxComments extension replaces the Talk page functionality with comments at the bottom of the page.

InstallationEdit

  • Download (Use the REL1_35 branch for version 1.35) and place the file(s) in a directory called AjaxComments in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php :
    wfLoadExtension( 'AjaxComments' );
    
  • Run the update script which will automatically create the necessary database tables that this extension needs.
  • Configure as required.
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

UsageEdit

This extension replaces the normal MediaWiki talk page functionality by allowing comments to be added at the bottom of the page or replies made to existing comments. Authors can edit or delete any of their comments as long as no replies have been made to them, and sysops can edit or delete any comments at all (deleting a comment with replies will also remove all the replies). The system is mainly JavaScript and jQuery and all updates are done via Ajax. The discussion data is stored in a new table named ajaxcomments and has the following structure.

MariaDB [-]> DESCRIBE ajaxcomments;
+-----------+------------------+------+-----+---------+----------------+
| Field     | Type             | Null | Key | Default | Extra          |
+-----------+------------------+------+-----+---------+----------------+
| ac_id     | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| ac_type   | int(10) unsigned | NO   |     | NULL    |                |
| ac_parent | int(10) unsigned | YES  |     | NULL    |                |
| ac_user   | int(10) unsigned | YES  |     | NULL    |                |
| ac_page   | int(10) unsigned | YES  |     | NULL    |                |
| ac_time   | int(10) unsigned | YES  |     | NULL    |                |
| ac_data   | text             | YES  |     | NULL    |                |
+-----------+------------------+------+-----+---------+----------------+
7 rows in set (0.134 sec)

To learn more about the project history, please see https://organicdesign.nz/AjaxComments for historical info.

ConfigurationEdit

Here are some global variables which affect the operation of the extension. These should be set in your LocalSettings file after the extension is registered.

Variable Default value Meaning
$AjaxCommentsLikeDislike false Add a like/dislike link to each comment
$AjaxCommentsAvatars true Use the Gravatar service for users icons
$AjaxCommentsPollServer 0 Poll the server to see if any changes to comments have been made and update if so
$AjaxCommentsEmailNotify true If set, sends notification of replies and activity on watched pages to users by email
$AjaxCommentsAdmins sysop List of groups that have admin priviliges for comments

HooksEdit

Comments extension adds three hooks, AjaxCommentsCheckTitle, AjaxCommentsCheckWritable and AjaxCommentsChange.

Hook name When is it called Parameters
AjaxCommentsCheckTitle Called when user rights are set. Allows for external conditions to manipulate if comments should be shown in the passed title.
  • $userpage (page title)
  • &$ret (boolean - whether comments should be shown in a given page, defaults to true)
AjaxCommentsCheckWritable Just before the content is loaded to allow adding external conditions for whether comments can be added or replied to.
  • $title (page title)
  • &$canComment (boolean - defaults to true if user is logged in)
AjaxCommentsChange Called in AjaxComments::add, AjaxComments::reply, and AjaxComments::delete. Called after inserting the comment or reply and before deletion.
  • $text (either 'add', 'reply', or 'delete')
  • $page (page id)
  • $id (user id)