Annonce

Important : WordPress 2.6 est disponible en français. À lire avant la migration !
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.

#1 23-03-2008 23:47:51

BenKenobi
Jedi WordPress
Lieu: Châteauroux
Date d'inscription: 19-09-2005
Messages: 4139
Site web

Doublon de trackback dans les commentaires

Bonjour,

Ma configuration WP actuelle
- Version de WordPress : 2.3.3
- Thème utilisé : Gossip City
- Nom de l'hebergeur : Free.fr
- Adresse du site : http://saint.maur.c.est.fou.free.fr

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

Le problème peut être visible ici.
Sur le site, les trackbacks sont différenciés des commentaires... enfin normalement ! En effet, on voit bien avant les commentaires les trackbacks dans la section "trackbacks" en mauve. Seulement dans les commentaires qui suivent, on retrouve le lien de trackbacks avec un résumé de l'article en question qui apparait aussi tel un commentaire. Comment le supprimer d'ici afin de ne conserver que le lien dans la zone mauve au dessus... et seulement celui-ci.

Je ne suis pas parvenu à trouver le code qui pose problème dans le thème.


Que la Force soit avec vous...

Hors ligne

 

#2 25-03-2008 19:15:45

BenKenobi
Jedi WordPress
Lieu: Châteauroux
Date d'inscription: 19-09-2005
Messages: 4139
Site web

Re: Doublon de trackback dans les commentaires

J'ai épluché mon fichier comments.php mais je ne vois pas où modifier ce paramètre... je pense pourtant que c'est dans ce fichier là qu'il faut agir...

Qu'en pensez-vous ?

Voici pour info mon fichier comments.php :

Code: php

  1. <div class="Comments">
  2. <div class="List">
  3. <!-- Start CommentsList-->
  4. <?php // Do not delete these lines
  5. if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
  6. die ('Please do not load this page directly. Thanks!');
  7. if (!empty($post->post_password)) { // if there's a password
  8. if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) {  // and it doesn't match the cookie
  9. ?>
  10. <p class="nocomments">Cet article est prot&eacute;g&eacute;. Entrez le mot de passe pour lire l'article et ses commentaires.<p>
  11. <?php return; }}?>
  12.  
  13. <!-- You can start editing here. -->
  14. <?php if ($comments) : ?>
  15. <h3 id="comments"><?php comments_number('0 commentaire', '1 commentaire', '% commentaires' );?> pour "<?php the_title(); ?>"</h3>
  16. <ol>
  17.  
  18. <?php foreach ($comments as $comment) : ?>
  19. <li class="ComListLi" id="comment-<?php comment_ID() ?>">
  20. <div class="ComListLiTop">
  21.  
  22.  
  23. <?php if (function_exists('gravatar')) { ?>
  24. <span class="ListGrav">
  25. <img src="<?php gravatar("R", 40); ?>" alt="<?php comment_author() ?>"/>
  26. </span>
  27. <?php } ?>
  28. <big><?php comment_author_link() ?></big>
  29. <small><a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('j F Y') ?> &agrave; <?php comment_time() ?><?php edit_comment_link('&nbsp;&nbsp;<strong>Modifier</strong>','',''); ?></a></small>
  30. <span class="ListNr"><? // php gravatar() ?><?php $commentNumber++; echo $commentNumber; ?></span>
  31.  
  32.  
  33.  
  34. </div>
  35. <span class="ListContent">
  36.   <p><?php comment_text() ?></p>
  37. </span>
  38. <?php if ($comment->comment_approved == '0') : ?>Votre commentaire est en attente de mod&eacute;ration.
  39. </li>
  40. <?php endif; ?>
  41. <?php endforeach; /* end for each comment */ ?>
  42. </ol>
  43. <?php else : // this is displayed if there are no comments so far ?>
  44. <?php if ('open' == $post->comment_status) : ?>
  45. <!-- If comments are open, but there are no comments. -->
  46. <?php else : // comments are closed ?>
  47. <!-- If comments are closed. -->
  48. <p class="nocomments">Les commentaires sont ferm&eacute;s.</p>
  49. <?php endif; ?>
  50. <?php endif; ?>
  51. <?php if ('open' == $post->comment_status) : ?><br />
  52. <!-- Ends CommentsList-->
  53. </div>
  54.  
  55.  
  56.  
  57.  
  58. <!-- Start Comments Form-->
  59. <h3 id="respond">Laissez un commentaire</h3>
  60. <div class="Form"><div class="FormTop"></div>
  61. <?php if ( get_option('comment_registration') && !$user_ID ) : ?>
  62. <p>Vous devez &ecirc;tre <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php the_permalink(); ?>">connect&eacute;</a> pour publier un commentaire.</p>
  63. <?php else : ?>
  64.  
  65. <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
  66. <?php if ( $user_ID ) : ?>
  67. <p style="display: block; margin-top: 5px; font-size: 10px; font-weight: bold;">Connect&eacute; en tant que <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&eaute;connexion de ce compte') ?>">D&eacute;connexion &raquo;</a>
  68. </p>
  69. <br clear="all" />
  70. <?php else : ?>
  71. <p>
  72. <label for="author">
  73. <small>Nom <?php if ($req) _e('(<strong>*</strong>)'); ?></small>
  74. <input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" tabindex="1" class="TextField" style="width: 400px;" />
  75. </label>
  76. </p>
  77.    
  78. <p>
  79. <label for="email">
  80. <small>E-mail (<?php if ($req) _e('<strong>*</strong>'); ?>)</small>
  81. <input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" tabindex="2" class="TextField"  style="width: 400px;" />
  82. </label>
  83. </p>
  84.    
  85. <p>
  86. <label for="url">
  87. <small><abbr title="Uniform Resource Identifier">URI</abbr></small>
  88. <input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" tabindex="3" class="TextField" style="width: 400px;" />
  89. </label>
  90. </p>
  91. <p>
  92. <label for="message"><small>Message</small>
  93. <?php endif; ?>
  94. <textarea name="comment" id="comment" rows="10" tabindex="4"  cols="10" class="TextArea" style="width: 400px;"></textarea>
  95. </label>
  96. </p>
  97. <p><input name="SubmitComment" type="image" class="SubmitComment" onmouseover="javascript:changeSty('SubmitCommentIE');" onmouseout="javascript:changeSty('SubmitComment');"  title="Validez votre commentaire" src="<?php bloginfo('template_url'); ?>/images/ButtonTransparent.png" alt="Validez" />
  98. <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" /></p>
  99. <?php do_action('comment_form', $post->ID); ?>
  100.  
  101. </form>
  102. <?php endif; // If registration required and not logged in ?>
  103. <?php endif; // if you delete this the sky will fall on your head ?>
  104. </div>
  105.  
  106. </div>

Que la Force soit avec vous...

Hors ligne

 

#3 25-03-2008 20:48:20

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

Re: Doublon de trackback dans les commentaires

Perso moi je fais 2 boucle sur les commentaire, la 1ère pour les tracback commence comme ceci:

Code: php

  1. <?php foreach ($comments as $comment) :
  2. $comment_type = get_comment_type();
  3. if($comment_type != 'comment') { ?>
  4.  
  5. <!-- ici le formatage des trackbak -->
  6.  
  7. <?php }
  8. endforeach; ?>

Et ensuite pour les commentaires:

Code: php

  1. <?php foreach ($comments as $comment) :
  2. $comment_type = get_comment_type();
  3. if($comment_type == 'comment') { ?>
  4.  
  5. <!-- ici le formatage des commentaires -->
  6.  
  7. <?php }
  8. endforeach; ?>

Voilà comme ça pas de soucis smile

Dernière modification par k-ny (25-03-2008 20:49:18)

Hors ligne

 

#4 27-03-2008 19:30:42

BenKenobi
Jedi WordPress
Lieu: Châteauroux
Date d'inscription: 19-09-2005
Messages: 4139
Site web

Re: Doublon de trackback dans les commentaires

k-ny > tes deux codes sont identiques là non ? c'est normal ?


Que la Force soit avec vous...

Hors ligne

 

#5 27-03-2008 19:42:17

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

Re: Doublon de trackback dans les commentaires

Non, il y a une toute petite différence ...

!= et ==

wink

Hors ligne

 

#6 27-03-2008 20:45:44

BenKenobi
Jedi WordPress
Lieu: Châteauroux
Date d'inscription: 19-09-2005
Messages: 4139
Site web

Re: Doublon de trackback dans les commentaires

Waoh... en effet, je n'ai pas encore l'oeil expert du codeur ! tongue

Et donc ces codes, je les mets à la suite de cette ligne dans mon fichier comments.php ?

Code: php

  1. <?php foreach ($comments as $comment) : ?>

Que la Force soit avec vous...

Hors ligne

 

#7 27-03-2008 23:48:04

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

Re: Doublon de trackback dans les commentaires

Oui, en fait tu remplaces cette boucle (qui commence donc par foreach et fini par endforeach):

Code: php

  1. <?php foreach ($comments as $comment) : ?>
  2. <li class="ComListLi" id="comment-<?php comment_ID() ?>">
  3. <div class="ComListLiTop">
  4. <?php if (function_exists('gravatar')) { ?>
  5. <span class="ListGrav">
  6. <img src="<?php gravatar("R", 40); ?>" alt="<?php comment_author() ?>"/>
  7. </span>
  8. <?php } ?>
  9. <big><?php comment_author_link() ?></big>
  10. <small><a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('j F Y') ?> &agrave; <?php comment_time() ?><?php edit_comment_link('&nbsp;&nbsp;<strong>Modifier</strong>','',''); ?></a></small>
  11. <span class="ListNr"><? // php gravatar() ?><?php $commentNumber++; echo $commentNumber; ?></span>
  12. </div>
  13. <span class="ListContent">
  14.   <p><?php comment_text() ?></p>
  15. </span>
  16. <?php if ($comment->comment_approved == '0') : ?>Votre commentaire est en attente de mod&eacute;ration.
  17. </li>
  18. <?php endif; ?>
  19. <?php endforeach; /* end for each comment */ ?>


Par:

Code: php

  1. <?php foreach ($comments as $comment) :
  2. $comment_type = get_comment_type();
  3. if($comment_type == 'comment') { ?>
  4. <li class="ComListLi" id="comment-<?php comment_ID() ?>">
  5. <div class="ComListLiTop">
  6. <?php if (function_exists('gravatar')) { ?>
  7. <span class="ListGrav">
  8. <img src="<?php gravatar("R", 40); ?>" alt="<?php comment_author() ?>"/>
  9. </span>
  10. <?php } ?>
  11. <big><?php comment_author_link() ?></big>
  12. <small><a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('j F Y') ?> &agrave; <?php comment_time() ?><?php edit_comment_link('&nbsp;&nbsp;<strong>Modifier</strong>','',''); ?></a></small>
  13. <span class="ListNr"><? // php gravatar() ?><?php $commentNumber++; echo $commentNumber; ?></span>
  14. </div>
  15. <span class="ListContent">
  16.   <p><?php comment_text() ?></p>
  17. </span>
  18. <?php if ($comment->comment_approved == '0') : ?>Votre commentaire est en attente de mod&eacute;ration.
  19. </li>
  20. <?php endif; ?>
  21. <?php endforeach; /* end for each comment */ ?>


Et juste après (ou avant) tu ajoute l'autre boucle et la tu personnalise la structure html de tes trackback :

Code: php

  1. <?php foreach ($comments as $comment) :
  2. $comment_type = get_comment_type();
  3. if($comment_type != 'comment') { ?>
  4.       <!-- ici le formatage des trackbak -->
  5. <?php }
  6. endforeach; ?>


Comme ça s'est séparer et personnalisé, clair et net !

Hors ligne

 

#8 27-04-2008 16:58:57

BenKenobi
Jedi WordPress
Lieu: Châteauroux
Date d'inscription: 19-09-2005
Messages: 4139
Site web

Re: Doublon de trackback dans les commentaires

Bon je suis vraiment pas doué, je n'arrive pas à mettre cela en place, j'obtiens toujours un message d'erreur lorsqu'il tente d'afficher les commentaires après les trackbacks.

Dois-je avoir qu'un seul endforeach ou un pour chaque boucle ? et comment faire pour mettre les 2 boucles à la suite... en fait c'est cela que je dois mal faire...


Que la Force soit avec vous...

Hors ligne

 

Pied de page des forums

Propulsé par PunBB 1.2.17
© 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