Wednesday, 08 April 2015 19:01

How to add Disqus (comment integration) into Joomla+K2

Written by

Before we begin, yes, K2 does have its own, built-in comment functionality.  And yes, there are plugins already built and available for this.  The reason I like this solution is twofold:

  1. K2's comment functionality, while has many useful features (Captcha anti-spam, email notifications, admin approval process), people seem to like using Disqus because it supports logins from multiple accounts (Disqus, Facebook, Google, Twitter).  K2's inbuilt commenting feature can be set up to allow comments from anonymous visitors, which opens up your site to comment spam.
  2. I don't like installing an entire plugin just to accomplish one little thing.  While I'm sure the plugin works, you have more customization / control when you handle the actual code.  This is similar to the plugins that allow you to add Google Analytics to your site - maybe it's just a pet peeve of mine - but I'd rather edit a (single, easy) file than install a new extension, which is a potential security risk.

Let's get started, shall we?  

Below are a few files you'll need.  

  • Add_to_template_index-dot-php.zip
    This file contains a code snippet that you'll need to add to your site template's "index.php" file.  This can sometimes be accomplished by going into Extensions -> Template Manager, and using one of the template parameters to inject the code (assuming your template has this feature).  Or, you can go into the actual template's index.php file using FTP and change it directly:  /your_site/templates/your_template/index.php
    In the code, you'll see a reference to a "forum shortname" which comes from your Disqus account; you'll need to change my text that says "CHANGE_THIS" to your actual shortname.
  • disqus-override.zip
    This will extract and give you a folder labelled "disqus" - it is a K2 template override, which means if you're using overrides properly, it will go here: /your_site/templates/your_template/html/com_k2/
    Otherwise, the standard location for K2 templates is here: /your_site/components/com_k2/templates
    The standard K2 template folder will be called "default" - I suggest adding the "disqus" folder alongside the default folder so that you can use the K2 category parameters to indicate which sections of your site use comments and which ones do not.

Inside the disqus (disqus-override.zip) folder, there are only two files that you need to pay attention to:

  • item.php (lines 98-106, and lines 691-703)
    In the code (line 691), you'll see a reference to a "forum shortname" which comes from your Disqus account; you'll need to change my text that says "CHANGE_THIS" to your actual shortname.
  • category_item.php (lines 122-124)
Last modified on Wednesday, 08 April 2015 19:38

Latest Comments

Got a similar email that seemed suspicious. Ignored it and they even followed up today.
My organization received one of these emails from "Linda," but uses https://www.bestprosintown.com/p...
Angela Snowman posted a comment in Link Building SEO Directory Scam Alert: loc8nearme.com
Hi Nate, I got the same email template from the same email address today and found you through a ...
Just received one today (16 Aug 2022) from "Mailchimp". Thanks for sharing!
Thanks for posting this. I just got one today. I was 99% sure it was a scam, and your post confirmed...


Design & Development

Wordpress, Drupal, Joomla
New custom websites
Bespoke themes and extensions
Redesigns, upgrades, migrations

Web Design & Development


Optimization & SEO

Let us optimize and manage your overall online presence. We offer full service monthly SEO as well as one-time projects.  

Optimization Plans & Pricing


Maintenance, Patching

White glove monthly backups, security updates, maintenance and testing for your Wordpress, Drupal, or Joomla site.

Maintenance Plans & Pricing


Email Newsletter

Bring your web & marketing performance to the next level: monthly blog post roundup via email.  

Stay in Touch!