BOMBOLOM.COM

(wordpress) Plugin: Hide or Show Comments

Posted by José Lopes.

This plugin provides an easy way to have the comments hidden by default, with a link to show the comments when requested by the visitor.

The objective of such functionality aims to focus the visitor attention on the post content.
In fact a large number of visitors just want to read the post and not the comments, but if they do want to read or leave their own comments they have the link to click and see them.

All the comments block stays hidden while using this Plugin, considering as comments block the comments list and form to leave a comment.
In its place the sentence 'Click here to see or add comments' will appear.

A visitor clicking in this sentence will make it go away, being replaced by the comments block. Once clicked the sentence will not return and the comments block will stay unless a page refresh is done.

To see this Plugin in action you can see the paleografia.org web site, at the bottom of the post. Note that this site is in Portuguese but you can see how the Plugin works with the 'Clique aqui para comentar ou ver comentários a este artigo' sentence at the bottom.

Download

You can download one of the files that serves you better:

You may also find this Plugin in the Wordpress repository at Hide or Show Comments

Installation

How to use it

Once active you have to do one thing to have it working.
The file single.php defines how to show the post itself, including the add comments form and list.

In this file you have to replace <?php comments_template(); ?> by <?php hideshowComments(); ?>. Now its done!

Final notes

This Plugin was tested with Wordpress v.2.2, so any info about other version is welcome.

There are no special requirements to install this Plugin, but to use it is necessary that the visitor's browser has the javascript activated.

This Plugin (in English by default) includes portuguese (Portugal) and french (France) versions, through the files with .mo extension available on the distribution.
The file hideshowcomments.pot allows the translation to any other language, that can be done easily since there is only one sentence to translate.

I leave the request for anybody adding a new language to send us the file so we can make it available to others.

2007.09.19 | There's more... | Comments 35 | Tags ,
Comment by jon on Thu Sep 27 16:27:18 2007
Hi There,
Great plug-in. Just wondered.. how would i make the link so that it would hide the comments as well.

At the moment, it only shows them.

thanks a lot for your help!
Comment by José Lopes on Thu Sep 27 23:26:40 2007
Hello Jon
I'm glad you liked the plug-in. If you want to add the hide comments feature you can:

1. Edit the file hideshowcomments.php
2. Between the lines:
<div id=\"hide\" style=\"display: none;\">
", comments_template(), "</div>";

Add the following code:

<center>
<a href=\"#\" style=\"text-decoration:none\" onclick=\"togLayer('show');return false;\" title=\"\">
Click here to hide again the comments</a>
</center>

3. Save the file and you have now a new link to hide back the comments.

I will include the hide option in the plugin as soon as I have a moment (next day or two).

Thanks for you suggestion.
Comment by mark on Sun Sep 30 19:10:05 2007
hi

is good

but how to get link to dynamically display number of comments:

'comment 3'

?

mark
Comment by José Lopes on Mon Oct 1 21:39:26 2007
Hi Mark
I assume you are talking about displaying the comments when you click on the comments link, that is before the "Click here to see or add comments".
Well, if you do click nothing happens. You really have to click on the plugin link to see the comments. It hides and shows the entire comments block and the number of comments is out.
As the plugin is writen the only solution is to include the number of comments on the "Click here to see or add comments" link.
The easier way to do it is to edit the hideshowcomments.php file and add next to '$linkText,' something like:
" (total comments ", comments_number('0','1','%'), ")",
With the comma at the end.

This adds the total of comments.
To be nicer you may remove the previous comments link and you can always change the english a bit to "Click here to add or see comments" and the just add:
" (", comments_number('0','1','%'), ")",

I will include an option argument on the next version to add the total of comments whenever the user wants it.

I will release the new version at the end of the month, giving time for more suggestions.
Comment by DeuceD on Tue Oct 23 10:34:39 2007
hello

Well your plugin is nice but not very usefull for me. I get really long comments and i was looking a way to show part of them and let the user expand them if he wanted. So i thought i could hack your plugin a bit.

My main problem is how could i set the $linkText1 which has the "post link" in a way to point to "comment ID". If i suceed it i can place to the comment loop at comment.php a line pointing to your script.

I would appreciate any suggestion

Greetings from greece
Comment by José Lopes on Tue Oct 23 16:38:23 2007
Hello DeuceD

My plugin is really all or nothing.

I see want you mean but I can't give you right away an answer. I have to check how it can be done and I will came back to you later!

Bye
Comment by José Lopes on Sat Oct 27 13:37:19 2007
Hello everybody,
I took a look for the question of posts with a lot of comments, in order to have just a few comments shown and with a link to expand the list showing everything.
I first started to change the comment.php file but then I decided to do another plugin (more simple!).

You may find the plugin 'Maximum Number of Comments' on this site.

DeuceD it should be what you are looking for, and it can be also used with the 'Hide or Show Comments' plugin.
Comment by Felipe on Thu Nov 1 19:33:44 2007
Como você eh de Portugual, irei falar em português =]

Gostaria de saber como mudo o estilo do texto de Click here to hide again the comments e Click here to see the comments or add a new comment.
Gostaria de aumentar o tamanho da fonte e mudar a cor, poderia me dizer como?
Comment by José Lopes on Thu Nov 1 23:11:38 2007
Viva Felipe
Tem tudo a ver com o Cascading Style Sheet (CSS). Ambos os links herdam a formatação do CSS do Tema que utiliza.
Para resolver o seu caso, dentro da directoria do seu Tema tem um ficheiro com a extensão css, algo do tipo style.css
Edite-o e deve encontrar algo como:
.comments {
Verifique se não tem nenhuma linha a começar por:
.comments a {
Se tiver muda-a c.c. pode acrescentar ao ficheiro:
.comments a {font-size:14px; color:red;}
Ambos os links aparecem dentro da classe comments pelo que é nela que temos de definir o estilo.
Não sei se está à vontade com CSS mas é relativamente simples. Para referência sugiro o site http://www.w3schools.com/css/default.asp
Comment by Jérôme on Mon Nov 26 10:50:51 2007
Hi José,

Your plugin is very well but i would to show/hide comments in the same page to the follow of my article (with index.php file, no single.php). I don't know to do that. Can you help me plese?
Comment by Jérôme on Mon Nov 26 10:52:31 2007
i verify to my comment is not a spam. :o)
Comment by José Lopes on Wed Nov 28 01:46:10 2007
Hi Jérôme
Are you by any chance french? It seems by the link to your site.
Si j'ai pas bien compris ta question, tu as sur ton index.php les commentaires sur chaque article et tu veux mettre là le show/hide comments? Tu utilises un Theme comme le classique?
De tout façons, je crois qu'il sera suffi de remplacer <?php comments_template(); ?> par <?php hideshowComments(); ?>

Par contre j'ai vu ton site et je trouve toutes les commentaires visible quand nous voyons un seul article. Enssaye de changer ce qui j'ai dit sur ton index.php
Si n'était pas bien ça ta question ou s'il marche pas, dit moi!
Comment by Carlos on Tue Jan 1 20:22:34 2008
Wonderful! Just one question... how can I make so when you write a comment the page is shown with the comments displayed? Right now you post a comment and it reloads the page with the comments box hidden, so its kind of a no-no. Otherwise great great work! Thanks for sharing!
Comment by José Lopes on Mon Jan 14 16:03:01 2008
Hello Carlos
You got me on the only thing that I quite don't like on the plugin. I have the intention to take a look at it and solve this boring feature, as you say is not logic once you comment you don't have the comments displayed.
I'm in the middle of some professional projects so I can't tell you when I will have the time to release a new version with this problem fix. Hope in the next month.
Thanks for the feedback!
Comment by K.Z. on Mon Feb 4 13:44:36 2008
hi..i reallyyyyyyyyyyy love your plug-in but i was just wondering 2 things:
1. how can i use this function (plug-in) to show me the comments on the main page of the post without moving to another page (i mean exactly when you click the # comments link at the top of the post to load the comments and the add coment box);
and 2. is there a way to use it with the AJAX Comments 2.0 plug-in ??? because now both of the plug-ins are active bur the AJAX Comments 2.0 doesn't work !!!

PLS answer my question !!!
THANK YOU in advance !!!
Comment by José Lopes on Fri Feb 8 14:38:56 2008
Hello KZ
The comments and the comment form are loaded with the post page. They are only hidden by default and shown on demand. Maybe I'm not hunderstanding what you say, just let me know if so.
About the ajax comments I'm not aware of the plugin and its requirements to give you an answer about compatibility problems. From my plugin side there should not be a problem with others. I'm short on time to give it a go but I'll try to see it during the next week. I'll letyou know what I may find.
Regards
Comment by Lori on Sun Feb 10 01:09:31 2008
Jose,

I installed your plugin and replaced <?php hideshowComments(); ?> in my index.php file. But when I go to my website and  click on the link to hide or show comments, nothing happens. Can you tell if i installed it wrong? thanks for your help...
Comment by José Lopes on Mon Feb 11 01:17:26 2008
Hello Lori
The plugin should be activated through the single.php file and not the index.php
I saw your site and I believe that you are using the classic theme, where the comments are access by a popup window.
The way the classic theme is design its not compatible with my plugin because it places a link for the comments instead of displaying the comment block. So, when using my plugin, it counts the number of comments but fails to get the comment block because the orginal theme uses another function.
Sorry for the bad news!
Nevertheless let me ask you, what did you replaced by <?php hideshowComments(); ?>, did you had comments displayed before? I may give you an hint to fix your problem.
Comment by Lori on Mon Feb 11 05:29:54 2008
Thank you for answering me. I was afraid that was my problem like you described.

My comments have always been accessed from a popup screen, which I would like to change anyways. I will try to figure out how to change that, and then hopefully I can use your plugin.

To answer your question, I had tried replacing <?php comments_popup_link> with your line of code <?php hideshowComments(); ?> but thats where i was getting the error.
Comment by Renato Barros on Sat Mar 22 13:28:46 2008
Convite a ver o país mais pequeno do mundo e a pedir a INTERNACIONALIZAÇÃO

--
Com os melhores cumprimentos
um forte abraço do Ilhéu da Pontinha Renato Barros
www.fortesaojose.com
Comment by An Cailin on Sun Apr 6 05:38:17 2008
This plugin does work with Wordpress 2.5!
Comment by José Lopes on Mon Apr 7 16:44:20 2008
Many thanks An Cailin for the info!
Comment by Lucas-man on Wed Jun 4 21:17:35 2008
Hi José,

I believe I saw something of an answer already, but i'm not sure. Is it possible to click on a link in index.php which opens the article (single.php) with the comments?

Under every article I state the number of comments for that article. With your plugin, when the article title is pressed single.php is loaded, the comments are hidden. I would like to load single.php with the comment showed when pressed in the link which mentions the number of comments for that post!

I you take a look at www.littlegreenfootballs.com at the end of a post you see the number of comments. When you press this link the article is showed with the comments. When you press on the article title its hidden.

Thanks,
Great plugin!
Comment by José Lopes on Mon Jun 9 14:31:53 2008
Hello Lucas-man
You must change the original plugin.
You may change the single.php to place the hide/show link on the post title, with the default showing the comments.
The plugin uses a simple javascript to do the hide and show, associating a div, but it displays blocks of text. To do what you want, using the same logic, you must create two blocks each with the post text, but one including the comments block.
The one with the comments, that you get on the first load, would be inside the div:
<div id="show" style="display: block;">
While the one hidding would be inside:
<div id="hide" style="display: none;">
You must keep in mind that it works in blocks, so the link to hide/show must be in a block, you can't have it outside the block.
Comment by Artriste on Thu Jun 26 17:10:20 2008
Bonjour José,

j'utilise ton plugin sur mon Wordpress avec un thème qui ne contient pas le comments_template() par défaut. Le thème utilise un comments_popup.php personnalisé pour les commentaires. Je ne peux donc pas styliser les commentaires avec ton plugin.

Y a-t-il une façon de changer comments_template() dans ton php pour charger le comments_pop.php à la place?

Ou encore mieux, comment puis-je ajouter le default comments_template dans la list "Theme Files" afin de me permettre de changer le style?

Tout le reste fonctionne à merveille par contre. Merci de ce plugin!
Comment by Artriste on Thu Jun 26 17:47:42 2008
José, j'ai trouvé une solution... beaucoup plus simple que j'avais imaginée. J'ai simplement renommé le fichier comments-popup.php fourni avec le thème que j'utilise par comments.php. J'ai du modifier quelques lignes puisque le code était conçu pour apparaître en pop up.

Il y a un autre élément sur lequel tu pourrais peut-être m'aider. J'aimerais que la page "descende" à la hauteur du premier commentaire, comme avec un "Encre" en html. Est-ce possible?

Pour l'instant, j'ai l'impression que plusieurs utilisateurs ne verront pas qu'une liste de commentaire vient d'apparaitre puisqu'il n'y aucun changement dans la page autre que "Hide comments". Je pense que ce serait une addition essentiel à ton merveilleux plugin.

merci encore
Comment by José Lopes on Fri Jun 27 01:03:06 2008
Salut Artriste
Une fois que tu montre les commentaires ils devraient apparaître jusqu'en bais du lien. Est-ce que puis me donner le lien de ton site pour voir ce qui ce passe.
Merci
Comment by Artriste on Fri Jun 27 20:07:17 2008
Oui, les commentaires apparaissent sans problème, en dessous du lien. Par contre la page demeure à la même "hauteur' lorsque le lien est cliqué, autant sur mon site que sur ton exemple: http://www.paleografia.org/site/?p=22#more-22

Ce que j'aimerais, c'est que la partie supérieur de mon navigateur (firefox) soit à égalité avec le lien "show-hide comments" lorsqu'il est cliqué, de sorte qu'on voit les premiers commentaires sans devoir "scroller".

est-ce possible?
Comment by Robert on Tue Jul 22 20:03:25 2008
Wonderful plug in!!! Thank you!!! Wondering if you can help me with a weird error message that comes up when I try to log out of WordPress. Here it is:

Warning: Cannot modify header information - headers already sent by (output started at /home/northlan/public_html/wp-content/plugins/hide-or-show-comments/hideshowcomments.php:86) in /home/northlan/public_html/wp-login.php on line 202

Warning: Cannot modify header information - headers already sent by (output started at /home/northlan/public_html/wp-content/plugins/hide-or-show-comments/hideshowcomments.php:86) in /home/northlan/public_html/wp-login.php on line 214

Warning: Cannot modify header information - headers already sent by (output started at /home/northlan/public_html/wp-content/plugins/hide-or-show-comments/hideshowcomments.php:86) in /home/northlan/public_html/wp-includes/pluggable.php on line 565

Warning: Cannot modify header information - headers already sent by (output started at /home/northlan/public_html/wp-content/plugins/hide-or-show-comments/hideshowcomments.php:86) in /home/northlan/public_html/wp-includes/pluggable.php on line 566

Warning: Cannot modify header information - headers already sent by (output started at /home/northlan/public_html/wp-content/plugins/hide-or-show-comments/hideshowcomments.php:86) in /home/northlan/public_html/wp-includes/pluggable.php on line 569

Warning: Cannot modify header information - headers already sent by (output started at /home/northlan/public_html/wp-content/plugins/hide-or-show-comments/hideshowcomments.php:86) in /home/northlan/public_html/wp-includes/pluggable.php on line 570

Warning: Cannot modify header information - headers already sent by (output started at /home/northlan/public_html/wp-content/plugins/hide-or-show-comments/hideshowcomments.php:86) in /home/northlan/public_html/wp-includes/pluggable.php on line 571

Warning: Cannot modify header information - headers already sent by (output started at /home/northlan/public_html/wp-content/plugins/hide-or-show-comments/hideshowcomments.php:86) in /home/northlan/public_html/wp-includes/pluggable.php on line 572

Warning: Cannot modify header information - headers already sent by (output started at /home/northlan/public_html/wp-content/plugins/hide-or-show-comments/hideshowcomments.php:86) in /home/northlan/public_html/wp-includes/pluggable.php on line 689
Comment by Jürgen Reschke on Fri Aug 29 13:39:23 2008
Hi José,

I tested your plugin with my site, but I am afraid I can't use it with wordpress 2.6.1. The plugin works good on the website, but I could not work with my wp-admin any longer. So I had to deinstall the plugin. Do you have any idea?
Comment by Jürgen Reschke on Fri Aug 29 14:32:50 2008
Hi José,

now it seems to work. Sorry for confusion, but I really don't know why.
Comment by Hannes on Tue Sep 30 01:14:16 2008
Nice plugin. I would remove the <center> tag that wraps the link. Centering is presentation and should be done via CSS.

I would also make the "hide" and "show" ids more unique. HTML element identifiers need to be unique per page and "hide" or "show" are just too likely to collide with another plugin or built-in code on the page.
Comment by Mark on Tue Oct 21 17:16:42 2008
i am getting the follwing error message after a comment has been posted

Warning: Cannot modify header information - headers already sent by (output started at /f1/content/*/public/wp-content/plugins/hide-or-show-comments/hideshowcomments.php:1) in /f1/content/*/public/wp-includes/pluggable.php on line 770

Is there any fix for this?

The comment still gets posted, but i get a white screen with this message after posting the comment.
Comment by Mark on Tue Oct 21 17:26:05 2008
p.s. i also got a similiar error message when i logged out out, and when i tried to disable the plugin.

wordpress 2.5
Comment by Mark on Thu Oct 23 15:50:45 2008
i got this working with no errors.

I upgraded to wordpress 2.6.2, but i dont think thats how i solved the problem.

I was changing the text for showing / adding comments to something else. For some reason, that was causing me to get the error messages.

I have left everything as it orginally was and it works fine.

Thanks for this plugin, this is exactly what i needed!

Deixe a sua mensagem:

Nome:


E-mail:


URL:


Comment:

Secret number

To send you comment you must insert the "secret number" on the box


Made with PyBlosxom | Add to Google