Annonce

Important : WordPress 2.5.1 est disponible.
Annonce 1 : Le Codex en français a besoin de vous pour avancer !
Annonce 2 : Avant de poster, n'oubliez pas de faire une petite Recherche et de lire les règles de ce forum.
  • Index
  •  » Thèmes
  •  » xéparer commentaires et trackback: comment faire.

#1 31-03-2008 14:49:10

Playmobil J
Habitué WP
Lieu: Nord
Date d'inscription: 22-09-2007
Messages: 91
Site web

xéparer commentaires et trackback: comment faire.

Bonjour,

Ma configuration WP actuelle
- Version de WordPress : 2.3.3
- Thème utilisé : codrobo
- Plugins en place :
- Nom de l'hebergeur :  infomaniak
- Adresse du site :

Problème(s) rencontré(s) :

je trouve que les trackbacks gênent la lisibilité des commentaires. Je voudari les séparer et j'ai donc suivi ce tuto:
http://www.ikiru.ch/blog/2005/separer-p … mmentaires

mais je n'y arrive pas, j'ai des erreurs php.

voici mon fichier comment.php

Code:

  1. <?php
  2.  
  3. /** For some reasons needed one more time **/
  4.  
  5. load_theme_textdomain('CordoboGreenPark');
  6.  
  7. $aOptions = themeCordoboGreenPark::initOptions(false);
  8.  
  9. if (!file_exists(get_theme_root() . '/' . get_template() . '/styles/' . $aOptions['style'])) {
  10.   $aOptions['style'] = 'green';
  11. }
  12.  
  13. // If the style has a header that needs generating, do it.
  14. $sStyleFolder = get_theme_root() . '/' . get_template() . '/styles/' . $aOptions['style'] . '/';
  15.  
  16. ?>
  17.  
  18.  
  19. <div class="comments">
  20.   <div class="comments-nice-bg">
  21.     <div class="comments-nice">
  22.  
  23. <?php // Do not delete these lines
  24.   if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
  25.     die ('Please do not load this page directly. Thanks!');
  26.  
  27.         if (!empty($post->post_password)) { // if there's a password
  28.             if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) {  // and it doesn't match the cookie
  29.         ?>
  30.  
  31.         <p class="nocomments">This post is password protected. Enter the password to view comments.</p>
  32.  
  33.         <?php
  34.         return;
  35.             }
  36.         }
  37.  
  38.     /* This variable is for alternating comment background */
  39.     $oddcomment = 'alt';
  40. ?>
  41.  
  42. <?php if ($comments) : ?>
  43.   <h3 class="reply"><?php comments_number('Aucune R&eacute;ponse', 'Une R&eacute;ponse', '% R&eacute;ponse' );?> pour '<?php the_title(); ?>'</h3>
  44. <p class="comment_meta">Suivre les commentaires avec <?php comments_rss_link(__('<abbr title="Really Simple Syndication">RSS</abbr>')); ?>
  45. <?php if ( pings_open() ) : ?>
  46.   ou faire un <a href="<?php trackback_url() ?>" rel="trackback"><?php _e('TrackBack');?></a> pour '<?php the_title(); ?>'.
  47. <?php endif; ?>
  48. </p>
  49.   <ol class="commentlist">
  50.  
  51.   <?php foreach ($comments as $comment) : ?>
  52.     <li class="<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
  53.       <div class="comment_author">
  54.         <?php comment_author_link() ?> a dit :
  55. <?php
  56. if ( !empty( $comment->comment_author_email ) ) {
  57.   $md5 = md5( $comment->comment_author_email );
  58.   $default = urlencode( 'http://use.perl.org/images/pix.gif' );
  59.   echo "<img style='float: left; margin-left: 10px;' src='http://www.gravatar.com/avatar.php?gravatar_id=$md5&amp;size=60&amp;default=$default' alt='' />";
  60. }
  61. ?>
  62.       </div>
  63.  
  64.       <?php if ($comment->comment_approved == '0') : ?>
  65.         <em>Votre commentaire sera publi&eacute; apr&egrave;s mod&eacute;ration.</em>
  66.       <?php endif; ?>
  67.       <br />
  68.  
  69.       <p class="metadate">le <?php comment_date('j F Y') ?> @ <?php comment_time() ?> <?php edit_comment_link('EDITER',' | ',''); ?></p>
  70.    
  71.  
  72.  
  73.       <?php comment_text() ?>
  74.  
  75.     </li>
  76.  
  77.   <?php /* Changes every other comment to a different class */ 
  78.     if ('alt' == $oddcomment) $oddcomment = '';
  79.     else $oddcomment = 'alt';
  80.   ?>
  81.  
  82.   <?php endforeach; /* end for each comment */ ?>
  83.  
  84.   </ol>
  85.  
  86.  <?php else : // this is displayed if there are no comments so far ?>
  87.  
  88.   <?php if ('open' == $post-> comment_status) : ?>
  89.     <!-- If comments are open, but there are no comments. -->
  90.    
  91.   <?php else : // comments are closed ?>
  92.     <!-- If comments are closed. -->
  93.  
  94. <div class="postinput">
  95.  
  96.       <p class="nocomments">Commentaires ferm&eacute;s.</p>
  97.    
  98.   <?php endif; ?>
  99. <?php endif; ?>
  100.  
  101.  
  102. <?php if ('open' == $post-> comment_status) : ?>
  103.  
  104.  
  105. <h3 id="reply">Poster un commentaire</h3>
  106.  
  107.   <div class="postinput">
  108.  
  109.  
  110.  
  111. <?php if ( get_option('comment_registration') && !$user_ID ) : ?>
  112.     <p>Vous devez etre <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php the_permalink(); ?>">connect&eacute; </a> pour poster un commentaire.</p>
  113.  
  114.  
  115.  
  116. <?php else : ?>
  117.  
  118. <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
  119.  
  120.  
  121.  
  122. <?php if ( $user_ID ) : ?>
  123.  
  124. <p>Connect&eacute; comme <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="<?php _e('D&eacute;connexion ') ?>">D&eacute;connexion  &raquo;</a></p>
  125.  
  126. <?php else : ?>
  127.  
  128. <p>
  129. <input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" />
  130. <label for="author"><small>Nom <?php if ($req) _e('(requis)'); ?></small></label></p>
  131.  
  132. <p>
  133. <input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" />
  134. <label for="email"><small>Mail (ne sera pas publi&eacute;) <?php if ($req) _e('(requis)'); ?></small></label></p>
  135.  
  136. <p>
  137.   <input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
  138.   <label for="url"><small>Website</small></label></p>
  139.  
  140. <?php endif; ?>
  141.  
  142. <p><textarea name="comment" cols="30" rows="5" id="comment" tabindex="4"></textarea></p>
  143.  
  144.  
  145. <p><input name="submit" type="image" id="submit" class="input-submit" tabindex="5" value="Envoyer" title="Relisez vous svp avant de poster" alt="Poster un commentaire" src="<?php bloginfo('stylesheet_directory'); ?>/styles/<?php if (isset($aOptions['style'])) { echo($aOptions['style']); } else { echo('green'); } ?>/images/post-a-comment.png" />
  146.  
  147.  
  148. <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
  149. </p>
  150. <?php do_action('comment_form', $post->ID); ?>
  151.  
  152. </form>
  153.  
  154.  
  155.  
  156.  
  157. <?php endif; // If registration required and not logged in ?>
  158.  
  159. <?php endif; // if you delete this the sky will fall on your head ?>
  160.  
  161.  
  162.  
  163.  
  164. </div> <!-- /post-input -->
  165. </div> <!-- /comments-nice -->
  166. </div> <!-- /comments-nice-bg -->
  167.  
  168.  
  169. </div> <!-- /comments -->

si vous avez une idée...

Hors ligne

 

#2 31-03-2008 14:59:32

k-ny
Passionné WP
Date d'inscription: 01-03-2008
Messages: 116
Site web

Re: xéparer commentaires et trackback: comment faire.

Hors ligne

 

#3 31-03-2008 15:35:53

Playmobil J
Habitué WP
Lieu: Nord
Date d'inscription: 22-09-2007
Messages: 91
Site web

Re: xéparer commentaires et trackback: comment faire.

ben suis un peu boulet et je n'arrive pas à voir comment transposer dans mon fichier comment.php. Remarque comme j'ai plusieurs thèmes ça veut dire que je vrais refaire la manip...

ça devrait être une fonction natif.

Dernière modification par Playmobil J (31-03-2008 15:37:10)

Hors ligne

 

#4 11-04-2008 15:36:51

jbj
Connaisseur WP
Lieu: Belgique
Date d'inscription: 06-08-2007
Messages: 27
Site web

Re: xéparer commentaires et trackback: comment faire.

La réponse est ici, mon ami smile

Hors ligne

 

#5 13-04-2008 23:38:13

Playmobil J
Habitué WP
Lieu: Nord
Date d'inscription: 22-09-2007
Messages: 91
Site web

Re: xéparer commentaires et trackback: comment faire.

jbj a écrit:

La réponse est ici, mon ami smile

Merci, mais ton code tu le mets où et dans quel fichier?

Hors ligne

 

#6 04-05-2008 13:35:17

wolforg
Membre WP
Lieu: Lozère
Date d'inscription: 18-04-2008
Messages: 4
Site web

Re: xéparer commentaires et trackback: comment faire.

Tout ceci est surement très efficace mais il y a plus simple (Spéciale dédicace à Bertrand Renard) :

Il existe le plugin BM-TrackPing qui permet de séparer tranquillement commentaires et trackbacks biere

La preuve en image, les trackbacks s'affichent en bas de page sous les commentaires .

resolu

Hors ligne

 

#7 04-05-2008 20:50:17

luneland
Connaisseur WP
Date d'inscription: 15-11-2007
Messages: 16

Re: xéparer commentaires et trackback: comment faire.

J'ai testé plusieurs solutions sans résultat et j'ai fini par trouvé ce code mais je ne sais plu ou ;(

Voilà le code a mettre dans un fichier que tu renomme "comments.php" et que tu mets dans ton thème, chez moi il fonctionne a merveille.

Code:

  1. <?php // Do not delete these lines
  2.   if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
  3.     die ('Please do not load this page directly. Thanks!');
  4.  
  5.   if (!empty($post->post_password)) { // if there's a password
  6.     if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) {  // and it doesn't match the cookie
  7.       ?>
  8.  
  9.  
  10.  
  11.       <p class="nocomments">Entrez le mot de passe pour regarder des commentaires.</p>
  12.  
  13.       <?php
  14.       return;
  15.     }
  16.   }
  17.  
  18.   /* This variable is for alternating comment background */
  19.   $oddcomment = 'alt';
  20. ?>
  21.  
  22. <?php
  23.   global $bm_comments;
  24.   global $bm_trackbacks;
  25.  
  26.   split_comments( $comments );
  27. ?>
  28.  
  29. <!-- You can start editing here. -->
  30.  
  31. <?php if ($comments) : ?>
  32.  
  33.  
  34.   <?php
  35.     $trackbackcounter = count( $bm_trackbacks );
  36.     $commentcounter = count( $bm_comments );
  37.   ?>
  38.  
  39.   <h3 class="Style1"><?php echo $commentcounter; ?> Commentaires</h3>
  40.  
  41.   <ol class="commentlist">
  42. <?php $cmntCnt = 1; ?>
  43.   <?php foreach ($bm_comments as $comment) : ?>
  44.  
  45.     <li class="<?php echo $oddcomment; ?> <?php if(function_exists("author_highlight")) author_highlight(); ?>" id="comment-<?php comment_ID() ?>">
  46.    
  47.          
  48.          
  49.           <span class="author_photo"><?php if(function_exists("MyAvatars")) MyAvatars(); ?> </span><?php ck_display_karma(); ?>
  50. <h6><?php echo($cmntCnt++); ?></h6>
  51.       <cite><?php comment_author_link() ?></cite> a &eacute;crit:
  52.       <?php if ($comment->comment_approved == '0') : ?>
  53.       <em>Votre commentaire est en attente de modération.</em>
  54.       <?php endif; ?>
  55.       <br />
  56.  
  57.       <small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('j F, Y') ?> &agrave; <?php comment_time() ?></a> <?php edit_comment_link('- Editer','',''); ?></small>
  58.  
  59.       <?php comment_text() ?>
  60.  
  61.     </li>
  62.  
  63.   <?php /* Changes every other comment to a different class */
  64.     if ('alt' == $oddcomment) $oddcomment = '';
  65.     else $oddcomment = 'alt';
  66.   ?>
  67.  
  68.   <?php endforeach; /* end for each comment */ ?>
  69.  
  70.   </ol>
  71.  
  72.   <?php if ( count( $bm_trackbacks ) > 0 ) { ?>
  73.  
  74.   <h2 class="commh2"><?php echo $trackbackcounter; ?> Trackbacks pour ce "post"</h2>
  75.  
  76.   <ol class="commentlist">
  77. <?php $cmntCnt = 1; ?>
  78.   <?php foreach ($bm_trackbacks as $comment) : ?>
  79.  
  80.     <li class="<?php echo $oddcomment; ?> <?php if(function_exists("author_highlight")) author_highlight(); ?>" id="comment-<?php comment_ID() ?>">
  81. <h7><?php echo($cmntCnt++); ?></h7>
  82.       <cite><?php comment_author_link() ?></cite>
  83.       <?php if ($comment->comment_approved == '0') : ?>
  84.       <em>Votre commentaire est en attente de modération.</em>
  85.       <?php endif; ?>
  86.       <br />
  87.  
  88.       <small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title=""></a> <?php edit_comment_link('Editer','',''); ?></small>
  89.  
  90.      
  91.  
  92.     </li>
  93.  
  94.   <?php /* Changes every other comment to a different class */
  95.     if ('alt' == $oddcomment) $oddcomment = '';
  96.     else $oddcomment = 'alt';
  97.   ?>
  98.  
  99.   <?php endforeach; /* end for each comment */ ?>
  100.  
  101.   </ol>
  102.  
  103.   <?php } ?>
  104.  
  105.  <?php else : // this is displayed if there are no comments so far ?>
  106.  
  107.   <?php if ('open' == $post->comment_status) : ?>
  108.     <!-- If comments are open, but there are no comments. -->
  109.  
  110.    <?php else : // comments are closed ?>
  111.     <!-- If comments are closed. -->
  112.     <p class="nocomments">Les commentaires sont clos.</p>
  113.  
  114.   <?php endif; ?>
  115. <?php endif; ?>
  116.  
  117.  
  118. <?php if ('open' == $post->comment_status) : ?>
  119.  
  120. <h2 class="commh2">L&acirc;che ta prose :</h2>
  121.  
  122. <?php if ( get_option('comment_registration') && !$user_ID ) : ?>
  123. <p class="alert">Vous devez &ecirc;tre <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php the_permalink(); ?>">connect&eacute;</a> pour voir les commentaires.</p>
  124. <?php else : ?>
  125.  
  126. <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
  127.  
  128. <?php if ( $user_ID ) : ?>
  129.  
  130. <p>Vous &ecirc;tes connect&eacute; comme :<a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">Quitter &raquo;</a></p>
  131.  
  132. <?php else : ?>
  133.  
  134. <p style="padding:10px 0px 10px 0px;"><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" />
  135. <label for="author"><small>Nom <?php if ($req) echo "(requis)"; ?></small></label></p>
  136.  
  137. <p style="padding:10px 0px 10px 0px;"><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" />
  138. <label for="email"><small>Courriel (ne sera pas publi&eacute;) <?php if ($req) echo "(requis)"; ?></small></label></p>
  139.  
  140. <p style="padding:10px 0px 10px 0px;"><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
  141. <label for="url"><small>Url</small></label></p>
  142.  
  143. <?php endif; ?>
  144.  
  145. <!--<p><small><strong>XHTML:</strong> You can use these tags: <?php echo allowed_tags(); ?></small></p>-->
  146. <div> <?php 
  147.  if ( function_exists(cs_print_smilies) ) { 
  148.  cs_print_smilies(); 
  149.  } 
  150.  ?> </div>
  151. <p style="padding:10px 0px 10px 0px;"><textarea name="comment" style="width:590px;padding:5px;" rows="10" id="comment" tabindex="4"></textarea>
  152. </p>
  153.  
  154. <p style="padding:10px 0px 10px 0px;"><input name="submit" type="submit" id="submit" tabindex="5" value="Z'y va" />
  155. <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
  156. </p>
  157. <?php do_action('comment_form', $post->ID); ?>
  158.  
  159. </form>
  160.  
  161. <?php endif; // If registration required and not logged in ?>
  162.  
  163. <?php endif; // if you delete this the sky will fall on your head ?>

Voila j'espère que cela te servira wink

Dernière modification par luneland (04-05-2008 20:52:55)

Hors ligne

 

#8 06-05-2008 11:19:37

Playmobil J
Habitué WP
Lieu: Nord
Date d'inscription: 22-09-2007
Messages: 91
Site web

Re: xéparer commentaires et trackback: comment faire.

wolforg a écrit:

Tout ceci est surement très efficace mais il y a plus simple (Spéciale dédicace à Bertrand Renard) :

Il existe le plugin BM-TrackPing qui permet de séparer tranquillement commentaires et trackbacks biere

La preuve en image, les trackbacks s'affichent en bas de page sous les commentaires .

resolu

salut,

merci, c'est simple et ça marche!big_smileresolu

Hors ligne

 
  • Index
  •  » Thèmes
  •  » xéparer commentaires et trackback: comment faire.

Pied de page des forums

Propulsé par PunBB 1.2.16
© Copyright 2005-2006 WordPress France

Tous droits réservés - wordpress-fr.net © 2005-2006

  • RSS
WPfr ValidatorXhtml ValidatorCSS mysql Php GetFirefox
Design par AmO - Crédits - Equipe WordPress France

Réseau International : Hongrie - Allemagne - Grèce - Italie - Japon - Corée - Suisse - Turquie - USA