DotClear : mettre en évidence les commentaires de l'auteur du billet
Par Benjamin le mercredi 15 décembre 2004, 19h28 - DotClear - Lien permanent - URL miniature
Certains se demandent comment faire pour mettre en évidence les commentaires de l'auteur d'un billet dans ce même billet. C'est assez simple dans la mesure où tout se base sur une condition...
Sous vos yeux ébahis les petites modifications.
dans /themes/opinionz/post.php (remplacer par le thème utilisé)
//on remplace <?php /* on affiche le commentaire */ ?> <blockquote> <?php dcCommentContent(); ?> //par <?php /* on affiche le commentaire */ ?> <blockquote<?php echo ($GLOBALS['comments']->f('comment_auteur') == $GLOBALS['news']->getUserCN()) ? " class=\"author-comment\"" : ""?>> <?php dcCommentContent(); ?>
puis on ajoute dans /theme/opinionz/style.css (remplacer par le thème utilisé)
#comments blockquote.author-comment { /* definir ici le style souhaité */ }
Voilà encore une modification super utile et facile à mettre en oeuvre 
Commentaires
Effectivement c'est quand même très con ça
J'ai trouvé, y'a une faute, enfin chez moi en tout cas, dans style.css, il faut mettre ça:
#comments blockquote.author_comment {
/* definir ici le style souhaité */
}
Au lieu de ça:
.post blockquote.author_comment {
/* definir ici le style souhaité */
}
je pense bien que tu as raison dans la mesure où je ne l'ai pas testé avec css
merci bien
Vache j'ai galéré, mais je te remercie pour l'effet rendu... mille merci à toi
Excellent !
Merci pour cette astuce qui fonctionne à merveille !
A ce sujet, quelle est la façon la plus simple de faire remonter les derniers commentaires en page d'accueil, comme c'est le cas chez toi?
Merci,
un peu de lecture :
www.brindilles.net/lune/i...
Bonjour Benjamin,
Je viens d'utiliser ton code et j'ai eus un peu de mal pour le mettre à l'oeuvre.
Dans post.php tu as : class=\"author-comment\"
et dans style.css tu as : comments blockquote.author_comment.
Une faute de frappe sans doute.
Encore merci pour ton code.
non pas du tout, en fait ce code :

#comments blockquote.author_comment
spécifie que le style de la classe ne s'applique qu'à un blockquote
contenu dans le div qui à l'id comments
Si, effectivement, y'a une'p'tit'erreur dans la propriété CSS :
// remplacez :
#comments blockquote.author_comment
// par :
#comments blockquote.author-comment
Bon, j'me la joue pas : suis nul en PHP ; alors : bravo! et merci pour cette manipe très simple et très efficace. Merci encore!
merci à toi, c'est édité
Bonjour,
Je débute complètement avec Dotclear, et cette fonction m'intéressait, mais le fait que n'importe qui pouvait "profiter" de la mise en forme spécifique des commentaires de l'auteur en utilisant son pseudo me gênait un peu.
Je ne connais rien du tout en php, mais j'ai quand même réussi à faire une petite modif qui "sécurise" un peu le principe :
Au lieu de comparer le nom de l'auteur du commentaire et celui du rédacteur, je compare l'adresse email de l'auteur du commentaire à une autre, secrete, conservée dans le fichier post.php.
Ca me donne ceci :
<blockquote<?php echo ($GLOBALS['comments']->f('comment_email') == 'monemail@secrete.com') ? " class=\"author-comment\"" : ""?>>Moi je trouve ce code beaucoup plus simple que celui proposé par le petit dotclear illustré... Il n'y a pas besoin d'inscrire quoique ce soit en dur. De toute façon sur mon blog, mon pseudo, c'est mon pseudo, j'edite si quelqu'un essaye de se faire passer pour moi!
<a href="http://www.movieworld.com.au/" rel="itsok">superb, coolblooded, profound nothing comparative to lazy</a> <a href="http://www.moviesounds.com/" title="rape do win - that is all that plane is capable of"> steal roll make - that is all that soldier is capable of: http://www.allmovie.com/ , white soldier becomes bad round in final
online directory main
génial ce code !
vraiment d'une aide très précieuse, bravo et merci :)))
Bonjour,
j'ai des soucis pour mettre en place le code. En effet, il y a déjà un style du même genre : #trackbacks blockquote, #comments blockquote{ border: 1px solid #EEE; margin: 1em 0; padding: 1ex 1em; } Lorsque j'ajoute le style : #comments blockquote.author-comment { background-color : #f7f7f7; border : 1px solid #cc0; }
les commentaires de l'auteur du commentaire sont bien distingués mais la structure du blog est explosée.
Des solutions ?
Merci
t'es sûr que t'as pas oublié de fermer une balise ou quelque chose du genre ?
Je ne crois pas. J'ai refait la manip plusieurs fois. Copier coller du script au bon endroit :
Voici mon fichier post.php
<div class="post"> <h2 class="post-title"><?php highlight::dcPostTitle(); ?></h2> <p class="post-info">Par <?php dcPostAuthor(); ?>, <?php dcPostDate(); ?> à <?php dcPostTime(); ?> <span>::</span> <a href="<?php dcPostCatURL(); ?>"><?php dcPostCatTitle(); ?></a> <span>::</span> <a href="<?php dcPostURL(); ?>" title="Lien permanent vers : <?php dcPostTitle(); ?>">#<?php dcPostID(); ?></a> <span>::</span> <a href="../../Bureau/<?php dcInfo('rss'); ?>?type=co&post=<?php dcPostID(); ?>" title="fil RSS des commentaires de : <?php dcPostTitle(); ?>">rss</a> </p> <?php dcPostChapo('<div class="post-chapo">%s</div>'); ?> <div class="post-content"><?php highlight::dcPostContent(); ?></div> </div>
<div id="comments"> <h3 id="co">Commentaires</h3> <?php if ($comments->isEmpty()) : /* Message si aucune commentaire */ ?> <p>Aucun commentaire pour le moment.</p> <?php endif; ?> <?php while ($comments->fetch()) : /* Boucle de commentaires */ // On met le numéro du commentaire dans une variable $co_num = $comments->int_index+1; ?> <p id="c<?php dcCommentID(); ?>" class="comment-info"> <span class="comment-number"><a href="#c<?php dcCommentID(); ?>"><?php echo $co_num; ?>.</a></span> Le <?php dcCommentDate(); ?> à <?php dcCommentTime(); ?>, par <strong><?php dcCommentAuthor(); ?></strong></p> <?php /* on affiche le commentaire */ ?> <blockquote<?php echo ($GLOBALS['comments']->f('comment_email') == 'aubermensuel@mairie-aubervilliers.fr') ? " class=\"author-comment\"" : ""?>> <?php dcCommentContent(); ?>
</blockquote> <?php endwhile; ?> <h3>Ajouter un commentaire</h3> <?php if (dcPostOpenComments() && dc_allow_comments) : /* Si les commentaires sont permis */?> <?php if (dc_allow_comments) : /* Si les commentaires sont permis */?> <?php include dirname(__FILE__).'/form.php'; ?> <?php endif; ?> <?php else : ?> <p>Les commentaires pour ce billet sont fermés.</p> <?php endif; ?> </div>
mon fichier style.css :
/* ***** BEGIN LICENSE BLOCK ***** * This file is the theme Tao Maï for DotClear. * Copyright (c) 2005 Thomas Taglang and contributors. All rights * reserved. * * DotClear is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * DotClear is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DotClear; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ***** END LICENSE BLOCK ***** * * Contributor(s): * Thomas Taglang */
@import url(../layout.css); /* Les éléments HTML en général -------------------------------------------------------- */ body{ background: #efefef; color: #666; font-size: 80%; line-height: 1.6em; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; }
h1, h2, h3, h4, h5, h6{ font-family: Arial, Helvetica, sans-serif; }
h1{font-size: 1.5em;} h2{font-size: 1em;} h3{font-size: 1.3em;} h4{font-size: 1.2em;} h5{font-size: 1.1em;} h6{font-size: 1em;}
h2 a:visited{color: #666;} h2 a:hover{color: #c30;}
pre, code{ font-size: 1.2em; }
pre{ width: 100%; overflow: auto; border: 1px solid #CCC; }
fieldset{ border: none; }
label{ cursor: pointer; }
.field label{ display: block; }
input,textarea{ border: 1px solid #666; background: #fff; color: #000; }
textarea{ width: 100%; font-size: 1em; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; }
a{ color: #666; }
a:visited{ color: #666; }
a:hover{ color: #c30; }
.left{ float: left; margin-right: 1em; } tao_sign .right{ float: right; margin-left: 1em; }
/* La page -------------------------------------------------------- */ #page{ background : #efefef url(../img/backgd.png) repeat-y center; color: inherit; } /* L'entête -------------------------------------------------------- */ #top{ height: 120px; background: #fff url(../img/banniere1.gif) no-repeat left top; }
#top h1{ height: 80px; line-height: 80px; margin: 0 0 0 0px; padding-top: 20px; color: #FFFFFF; text-align: center; }
#top h1 a{ text-decoration: none; color: #e2001a; font-size: 28px; text-align: center; }
/* Le prélude -------------------------------------------------------- */ #prelude{ background: transparent; color: #c30; text-align: center; }
#prelude a{ color: #eab919; background: transparent; }
#prelude a:hover{ color: #c30; background: transparent; }
/* Le contenu -------------------------------------------------------- */ .day-date{ display: none; color: #888; font-style: italic; }
.post-title{ color: #000; background: transparent; margin-bottom: 0; padding-left: 0px; height: 40px; background-position: 0 -0.2em; }
.post-title a{ color: #000; background: transparent; text-decoration: none; }
.post-info{ margin-top: 0; color: #eab919; background: transparent; border-bottom: 1px dotted #eab919; font-size: 0.8em; text-align: right; }
.post-info a{ color: #c30; background: transparent; text-decoration: none; }
.post-content{ text-align: left; padding-left: 10; }
.post-content blockquote{ font-family: Georgia, serif; font-style: italic; }
.post-info-co{ text-align: right; font-size: 0.8em; border-top: solid 1px #c30; background: #efefef; margin-right: -5px; margin-left: -5px; padding: 0 5px 0 5px; }
.post-info-co a{ text-decoration: none; }
#trackbacks blockquote, #comments blockquote{ border: 1px solid #EEE; margin: 1em 0; padding: 1ex 1em; }
#comments blockquote.author-comment{ background-color : #f7f7f7; border : 1px solid #cc0; }
/* La barre de navigation -------------------------------------------------------- */ #sidebar div{ /*border-bottom: 1px solid #F0F0F0;*/ color: inherit; }
#sidebar div ul{ margin: 0; padding: 0; list-style: none; }
#sidebar h2, #sidebar h3{ color: #c30; margin: 0 0 1ex 0; }
#sidebar h3{ font-size: 1em; margin: 0; }
#sidebar div#search{ background: transparent; color: inherit; /*line-height: 2.3em;*/ }
#search fieldset, #search p{ margin: 0; padding: 0; }
#q{ padding-left: 18px; background: #fff url(../img/q.png) no-repeat 4px; }
#sidebar div#calendar{ /*border-top: 1px solid #F0F0F0;*/ }
#sidebar div#calendar table{ font-size: 0.8em; text-align: center; margin: 0 auto; border-collapse: collapse; }
#sidebar div#calendar table caption{ margin: 0 auto; }
#sidebar div#calendar table th{ color: #666; background: transparent; }
#sidebar div#calendar table td{ width: 14%; line-height: 2em; border: 1px solid #ddd; }
#sidebar div#calendar table td a{ display: block; background: #eab919; color: #c30; font-weight: bold; text-decoration: none; }
#sidebar div#calendar table td a:hover{ background: #c30; color: #eab919; }
.apropos{ font-size: 0.8em; }
/* Le pied de page -------------------------------------------------------- */ #footer{ margin: 0; padding: 1em; border-top: 1px solid #c30; background: #efefef; color: #c30; text-align:center; }
#footer a{ color: #eab919; }
#footer a:hover{ color: #c30; }
span.highlight0 { background-color: #ffec00; }
En fait c'est le fichier style.css qui me pète la strcurure du site mais pourquoi ?
Merci