Integrating Disqus Page Comments - ΩJr. Publizjr Creates Web Pages

This information lives on a webpage hosted at the following web address: 'https://omegajunior.globat.com/code/publizjr/'.

19 Mar. 2012
A.E.Veltstra

Ooh, full-on Web 2.0, let's turn our visitors into contributors and let them write our website... and make us money in the process. That's what Hyves and Facebook did, and what CNN's iNews does.

Yeah, let's not. Let's just give our readers an easy way to provide feedback, ask questions, and correct us when we've got it wrong. Preferably with spam protection and moderation options.

One service that delivers these functions and offers a free plan, is Disqus. Here's how to implement the Disqus Page Comments functionality into the Publizjr Genrator Templates.

Obligatory Privacy Talk

Since May 2011, European Law requires a web site to request explicit consent from their visitors before they set most cookies, the exception being cookies needed for services requested explicitly by that visitor. The Page Comments feature is such an explicitly requested service. You need to tell your visitors that it uses cookies, and how it uses them. The visitor can then choose to use (or not use) the Page Comments feature.


Resuming Instructions

For the integration to be successful and having Disqus comments up and running, your client will need to provide their Disqus shortname. They may want to set up an account first. Disqus offers free plans, and OmegaJunior Consultancy happily uses one. No, we are no affiliate.


Get the code

The Disqus integration code unfortunately isn't part of the translations in the Required Parts Download, which we offer in the Publizjr Installation Documentation. Due to the fact that its configuration may very well depend on site hierarchy as well as the visitor's language prefences, the code has to be copied straight into the template.


Disqus Integration Code

Before you start copying, beware that some configuration is needed.

<hr>
<p class="cookiesDisqus">By using the Disqus feedback service below, you agree to receive cookies by Disqus and possibly other parties needed. You can avoid that by using e-mail.</p>
<div id="disqus_thread"></div>
<script>/* <![CDATA[ */
var disqus_shortname = "my_shortname";
var disqus_url = "http://www.mysite.com/?id=<?php print( $strFileID ); ?>";
var disqus_identifier = "<?php print( $strFileID ); ?>";
var disqus_category_id = "123456789";
/* when using the Multilanguage Publizjr Template, uncomment the function below */
/*
var disqus_config = function() {
this.language = "<?php print( $strRequestLang ); ?>";
};
*/
( function() {
var dsq = document.createElement( "script" );
dsq.type = "text/javascript";
dsq.async = true;
dsq.src = "//" + disqus_shortname + ".disqus.com/embed.js";
( document.getElementsByTagName( 'head' )[ 0 ] || document.getElementsByTagName( 'body' )[ 0 ] ).appendChild( dsq );
} )();
/* ]]> */</script>
<noscript>Please enable javascript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com/" class="dsq-brlink">Comments powered by <span class="logo-disqus">Disqus</span>.</a>



Configuring the code

There are 5 areas to configure:



Adding it to the template

We advise to place the page comments near the bottom of the template, in the page footer.

Then save the template under a different name, upload it to the hosting provider, request the template in a browser, and test. Once you're happy with the results, copy the change to the live templates.

If you run into any trouble, please let us know.

Interested?

Let's meet for coffee or over lunch. Talk to me using this form.