Highlight Author Comments in Drupal

ผมไปเจอวิธีการเปลี่ยนสีความคิดเห็นของผู้เขียนบทความ ให้มีสีที่แตกต่างจากความคิดเห็นของคนอื่น โดยเป็นการเพิ่ม class เข้าไปที่ความคิดเห็นของผู้เขียน จากนั้นเราก็ใช้ css นการตกแต่งให้มันแตกต่าง….

ให้ดูที่ไฟล์ comment.tpl.php ใน theme ที่เราใช้งาน โดยโค็ดที่เราจะแก้คือ

<div class="comment<?php print ($comment->new) ? ' comment-new' : ''; print ' '. $status; ?>">

ให้แก้เป็น

<div class="comment<?php print ($comment->new) ? ' comment-new' : ''; print ($comment->uid == $node->uid) ? ' author-comment' : ''; print ' '. $status;?>">

ต่อมาให้เพิ่ม css ด้านล่างลงไปที่ css หลักของ theme

/** Drupal comments **/
.author-comment
{
      background-color: #ff5;
      border: 1px solid #aaa;
}

นี่เป็น css เบื้อต้นเท่านั้นเราสามารถตกแต่งได้ตามสะดวกครับ

via : http://wesleybailey.com/articles/how-to-highlight-author-comments-drupal

บทความแนะนำ
    blog comments powered by Disqus