Installing DISQUS in MODx
A few days ago I mentioned upgrading my (very neglected) main site (hypercubed.com) to MODx revolution. I didn’t bother migrating the commenting system from the old site because it was rarely used. I didn't plan on implementing a commenting system at all on revolution. Then I had the simple idea of using DISQUS (pronounced discuss). DISQUS is that cross site commenting system you've undoubtedly seen on numerous blogs. For visitors it allows posting of comments using any one of several log-ins (twitter, facebook, etc) and, if they are using a DISQUS account, track comments across multiple websites.
As a site manager or blog owner you need to create an account at disqus.com then follow the simple instructions for installing the commenting system on your website or blog. Unfortunately, you will not find instructions for MODx. I'm sure most people running MODx are skilled enough to figure this out but here is my solution.
[[*alias]] but I what the ability to move pages (changing the alias) without orphaning the comments.
Now, simply adding this text to the template (working with templates) will enable comments on my site. However, I don't want to have comments on every page. So I placed the above HTML into a chunk (working with chunks) called
[[$comments?]]. Then I created a template variable (working with template variables) called
[[*Comments]] template variable has an input type of
Check Box, an input options values of
Enabled==1, and a default value of
Then in my template, where I wish to have the DISQUS comments appear, I added the following code:
[[If? &subject=`[[*Comments]]` &operand=`1` &then=`[[$comments?]]`]]
This tag uses the If snippet to check if the
[[*Comments]] template variable is enabled. If it is the DISQUS comments are shown. With this I can selectively turn comments on and off on individual pages.
This is just another example of the flexibility in MODx.