BOMBOLOM.COM

(wordpress) Plugin: Hide or Show Comments

Este é um post de José Lopes.

Este plugin disponibiliza uma forma fácil de esconder por defeito os comentários de um post, apresentando no seu lugar um link para mostrar os comentários caso o visitante do site o pretender.

O objectivo de uma funcionalidade como esta é de concentrar as atenções do visitante no conteúdo do post.
De facto, uma parte significativa dos visitantes de um site quer ler o post e não os comentários, mas caso desejarem ler ou deixar o seu próprio comentário têm um link que os disponibiliza.

Ao utilizar este Plugin todo o bloco de comentários fica escondido, em que considero como bloco a lista de comentários e a form para adicionar um comentário.
No seu lugar aparecerá a frase 'Clique aqui para comentar ou ver comentários a este artigo'.

Se o visitante clicar nesta frase ela desaparece e dá lugar ao bloco dos comentários. Uma vez clicada o bloco de comentários aparece e fica a menos que se faça um refresh da página.

Para ver este Plugin em acção pode ver no post no site paleografia.org, no fundo da página, um exemplo.

Download

Pode fazer o download de um dos ficheiros:

Também pode obter este Plugin no reportório do Wordpress em Hide or Show Comments

Instalação

  • Descomprimir o ficheiro para o directório wp-content/plugins
  • Será criada a directoria hide-or-show-comments aquando da descompressão, caso contrário deverá a criar manualmente e colocar os ficheiros do Plugin dentro dela.
  • Activar o Plugin Hide or Show Comments através do painel administrativo.
  • O Plugin fica assim disponível para utilização mas ainda temos de fazer uma coisa!

Modo de Utilização

Uma vez activado tem de ser implementado para executar as suas funções.
O ficheiro single.php contém as definições para mostrar o post em si, incluindo a form para adicionar comentários e a lista dos comentários efectuados.

Neste ficheiro tem de se substituir <?php comments_template(); ?> por <?php hideshowComments(); ?>. Agora funciona em pleno!

Notas finais

Este Plugin foi testado para a versão 2.2 do Wordpress, pelo que qualquer informação sobre a sua utilização em outras versões será bem vinda.

Não existem requesitos especiais para a intalação deste Plugin, sendo que a sua utilização requer que o browser de quem visite o site com o Plugin tenha o javascript activado.

Este Plugin (em inglês por defeito) também inclui uma internacionalização para português e francês com os ficheiros de extensão .mo disponibilizados para o efeito.
O ficheiro hideshowcomments.pot possibilita a tradução para qualquer outra língua, o que não é muito trabalhoso pois trata-se somente de uma frase.

Deixo o pedido para quem o faça que nos envie o ficheiro para podermos o disponibilizar a outros.

19.09.2007 | Ler mais | Comentários 35 | Tags ,
Comentário por jon em 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!
Comentário por José Lopes em 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.
Comentário por mark em Sun Sep 30 19:10:05 2007
hi

is good

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

'comment 3'

?

mark
Comentário por José Lopes em 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.
Comentário por DeuceD em 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
Comentário por José Lopes em 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
Comentário por José Lopes em 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.
Comentário por Felipe em 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?
Comentário por José Lopes em 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
Comentário por Jérôme em 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?
Comentário por Jérôme em Mon Nov 26 10:52:31 2007
i verify to my comment is not a spam. :o)
Comentário por José Lopes em 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!
Comentário por Carlos em 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!
Comentário por José Lopes em 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!
Comentário por K.Z. em 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 !!!
Comentário por José Lopes em 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
Comentário por Lori em 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...
Comentário por José Lopes em 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.
Comentário por Lori em 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.
Comentário por Renato Barros em 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
Comentário por An Cailin em Sun Apr 6 05:38:17 2008
This plugin does work with Wordpress 2.5!
Comentário por José Lopes em Mon Apr 7 16:44:20 2008
Many thanks An Cailin for the info!
Comentário por Lucas-man em 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!
Comentário por José Lopes em 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.
Comentário por Artriste em 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!
Comentário por Artriste em 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
Comentário por José Lopes em 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
Comentário por Artriste em 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?
Comentário por Robert em 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
Comentário por Jürgen Reschke em 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?
Comentário por Jürgen Reschke em Fri Aug 29 14:32:50 2008
Hi José,

now it seems to work. Sorry for confusion, but I really don't know why.
Comentário por Hannes em 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.
Comentário por Mark em 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.
Comentário por Mark em 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
Comentário por Mark em 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:


Comentário:

Número Secreto

Para enviar o seu comentário tem de inserir o "número secreto" no campo que está imediatamente à direita.

Voltar à Página principal | Made with PyBlosxom | Add to Google