Content last modified Tuesday 24 August 2021
hop to #bottom
Categories:
Author:
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:if_individual_article>
<txp:low_discuss />
<txp:low_discuss_form />
</txp:if_individual_article>

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:if_individual_article>
<txp:post_comments />
</txp:if_individual_article>

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. :)

Furthermore:

  • 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

You know you want to visit the Archives.
Published with Textpattern