Adding Disqus to Modx Evolution

If you would like to use Disqus instead of the built in comments try this.1. Create a disqus account; verify your email and log in to the account- remember your short name for step two.

1. Create a disqus account; verify your email and log in to the account- remember your short name for step two.

2. Grab the Universal Embed Code and create a new chunk named disqus- - when you use your short name in the URL to the left (replacing "yourusername") the user code should be correct for your unique site. I also concatenated the second bit of code called comment count which is supposed to be placed just before the </body> tag into the disqus chunk and it seems to work fine for me.

<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_shortname = 'yourusername';

(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
<noscript>Please enable JavaScript to view the <a href="">comments powered by Disqus.</a></noscript>
<a href="" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
<script type="text/javascript">
var disqus_shortname = 'yourusername'; // required: replace example with your forum shortname
(function () {
var s = document.createElement('script'); s.async = true;
s.type = 'text/javascript';
s.src = 'http://' + disqus_shortname + '';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);

3. Create a unique URL Identifier for Disqus. If you use the Modx document id variable it should always be unique.
For Modx Evolution use the following code just before your head tag:

<script type="text/javascript">
var disqus_identifier = '[*id*]';


4. Add a call to the disqus chunk in the content area of the page template(s). Just before the end of the div containing the content call: [*#content*], add {{disqus}} . Now you should be able to clear your site cache and test it.
To add a link to the comments area from the top of the page add an "a name" tag named "disqus" and build a URL from inside the page. e.g. <a href="news/blog/[*alias*].html#disqus">Comments</a></p> linking to <a name="disqus">&nbsp;</a>{{disqus}}

Comments (0)

Add a Comment

This thread has been closed from taking new comments.