Content last modified Monday 6 March 2017
hop to #bottom
About It:
Rate it:
  • Helpful?
  • 1 Yes
  • 0 No
Flag it:

If you'd like to provide updated information and do not have access to directly edit, please contact the site admin; thanks!

Hiding and customizing the comments form and system

This is the documentation of a few of the steps I took to achieve a customized comments system..

At the time of writing this, my real example site (built on RC3) is not available for me to show you, because it is still being built locally… i’ll launch it eventually as ferrydust version 2.

i’ve reproduced the results here at ferrydust version 1, very skeletally, mostly for illustrative purposes and to walk myself through my own instructions.

anyway.. i had stated in the forum that i would like to be able to:

have the comments show only when you click on ‘comments’, rather than having the comments and commentform (particularly) shown fully when on a single_article page.

so here’s how i successfully managed this on mine:

1. First, you’ll need the low_discuss plugin.

Download, install, and activate that plugin.

It will break up the comments system and give you essential tags:

<txp:low_discuss /> : Displays comments
<txp:low_discuss_form /> : Displays input form
<txp:low_comments_invite /> : Replaces <txp:comments_invite />

2. you will need to make one change to publish.php (in your /textpattern directory:

Search for $article .= discuss($ID);, and either delete it, or comment it out (just add a double slash like so: // at the start of the line). You should find it around line 389.

In your admin panel there’s a section at the bottom to set your preferenes for comments… set ‘comments_auto_prepend’ to No.

3. place:

<txp:low_discuss />
<txp:low_discuss_form />

in your article form where you would those to appear. (If you don’t surround those with the if_individual_article conditional, bad things are sure to happen.)

Time-out for a moment. Check and make sure all of this is working so far.

I found that low_discuss did NOT work on my RC1 installation, but it had worked flawlessly on my RC3 installation. However, it was released in December, tested for RC2…

So if you try the low_discuss tags and find they do not work for you, then as an alternative method use Chris McLeod’s Put comments anywhere on an article page instructions. (I compiled the plugin piece of his instructions.. you can get it here and install it regularly.)

So then you’ll be working with the following instead of low_discuss:
<txp:post_comments />

Now, for the hiding of the comments form:

4. You’ll need this very nice little script and instructions: Showing and Hiding a DIV using CSS and Javascript

You can probably take it from here on your own.. But i’ll continue talking a bit more about my process…

5. i took the function that’s there:

function toggleLayer(whichLayer)
if (document.getElementById)
// this is the way the standards work
var style2 = document.getElementById(whichLayer).style;
style2.display = style2.display? "":"block";
else if (document.all)
// this is the way old msie versions work
var style2 = document.all[whichLayer].style;
style2.display = style2.display? "":"block";
else if (document.layers)
// this is the way nn4 works
var style2 = document.layers[whichLayer].style;
style2.display = style2.display? "":"block";

and copied & pasted that into a stylesheet page on my Textpattern install (Presentation > Styles) .. i named it ‘showhide.js’. And call it through a form that is outputted on every Textpattern page.

Call it by putting this in your <head> :
<script type="text/javascript" src="<txp:css n="showhide.js"/>"></script>

I learned that technique from the excellent Mark Norton

6. Add the id style to your relevant style sheet ( #customcomments{display:none;}

and place <div id="customcomments"> all-your-comment-stuff-that-should-be-initially-hidden-should-go-here </div> in your article form, around <txp:low_discuss_form /> (or around <txp:post_comments />, whatever your case may be) and whatever else you want.

7. Somewhere outside the <div id="customcomments">, where you would like your comments invitation, add this: <a href="javascript:toggleLayer('customcomments');" title="Add a comment here">Add a comment</a>

8. In your comment_form form, probably next to where you have <txp:comment_submit />, place the following:
<input type="reset" name="reset" value="Cancel" onclick="javascript:toggleLayer('customcomments');" />

And that should do it. :)


  • In case it helps anyone else, i learned that you can call a script AND an anchor name from one link:
    <a href="#customcomments" onclick="toggleLayer('hiddencomments');">
    Thanks to Andrew Waer for that very useful answer.

  • I use my comment form/display (on ferrydustv2) with a heavy dosage of conditionals.. for those, download the glx_if plugin for conditional control over ouput and style.
  • i contacted Justin Low, who says he’d be happy to have someone else further develop his existing plugins, and expand their featureset (maybe new functionality is also available with the release of RC3 admin extensions..). So if anyone’s up for it… ‘would always be great to have further customization options….
  • i was using txp:akw_date_aware in place of txp:article (have been using it for a long long time now) and found that it conflicted with the comments customization… i realized i had the date_aware functionality double-backed by asy_showdate anyway, so i just replaced txp:akw_date_aware with txp:article and all went well.

this guide will be useful to me in the future when i’m trying to reproduce all of this.. meanwhile, maybe it will be helpful to someone else. please do let me know if the instructions are unclear at any point.

Article Request Count:
Initially released:
13 April 2005
Posted here:
14 Apr 2005
Article modified:
02 Aug 2005

If there is a comment form at the Information URL, you may want to leave your comments/questions there or at the Forum thread for quicker feedback. Otherwise, comment away:

Commenting is closed for this article.

Commented (7)

this works like a charm! so good. this is absolutely what I wanted! thanks
wow, this works perfectly for me, and just what i need. thanks a lot!

at first i messed up the publish.php file (uploaded the wrong one) and neither plugin worked. i ended up getting the comment form twice on the page. but i’ve slapped my forehead over it already hehe and it’s looking great.

i’ll just tweak my files a bit more.

thanks again!
oh, nice script, so timely for me, thanks!
Is this still working in the 4.03 release of textpattern? I’ve tried, but I get double comment forms and strange behaviour. Would probably have something to do with new nonce() behaviours…
I’ve been trying this solution lately (at 4.04 version) et get this javascript error here:
var frmvalidator = new Validator(“discuss_form”);

“Validator is not defined”.

Have I missed somthing ou are any additional js to add ?

Thanx …

You can do full customization using the built-in tags now.

Thank you for sharing the code in this article :)

Subscribe to this article's comments RSS feed. [ ? ]   View Recent Comments across the site.

Would you care to write a comment or visit the forum discussion?

You know you want to visit the Archives.




There are also tag clouds, 'cause those are fun.
Published with Textpattern