การทำเมนูแสดงหมวดหมู่ และจำนวน Node ทั้งหมดในหมวดหมู่นั้น

  • warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1005 is not allowed to access /tmp owned by uid 0 in /var/www/sites/sugree/codenone.com/subdomains/www/html/includes/file.inc on line 190.
  • warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1005 is not allowed to access /tmp owned by uid 0 in /var/www/sites/sugree/codenone.com/subdomains/www/html/includes/file.inc on line 190.

ใช้ Drupal ทำ WeBlog ส่วนตัว
และได้ใช้ Taxonomy เพื่อกำหนดหมวดหมู่ให้เนื้อหาแต่ละเรื่อง

ถ้าอยากให้ด้านข้างมี Block แสดงรายการหมวดหมู่ และแสดงจำนวนเรื่องทั้งหมดที่อยู่ในหมวดหมู่นั้น (จำนวน Node) ภายในเครื่องหมายวงเล็บ เหมือนกับ Sidebar ของ Wordpress

ตัวอย่าง

  • ไอที (5)
  • ธุรกิจ (11)
  • การตลาด (8)
  • สังคม (20)

อยากทราบว่าจะสามารถใช้วิธีไหนได้บ้าง, หรือมี Module ตัวใดที่สามารถทำแบบนี้ได้บ้างครับ
ขอบคุณครับ

ผมค้นหาได้ Code มาได้ดังนี้

><?php
$vid = 1;  // Set the vid to the vocabulary id of the vocabulary you wish to list the terms from
$items = array();
 
$terms = taxonomy_get_tree($vid);
foreach ( $terms as $term ) {
  $count = db_result(db_query("SELECT COUNT(nid) FROM {term_node} WHERE tid = %d", $term->tid));
  $items[] = l($term->name, "taxonomy/term/$term->tid") . " ($count)";
}
 
if ( count($items) ) {
  print theme('item_list', $items);
}
?></blockcode>
sugree's picture

เคยใช้ SiteMenu อยู่พักนึง

ย้าย Codenone

ประกาศย้าย Codenone ไปใช้ Forum ของ Blognone แทนครับ ตามไปตั้งกระทู้ต่อได้ที่ Codenone Forum (รายละเอียดอ่านจากกระทู้ ย้าย Codenone ไปรวมกับ Blognone)

กระทู้เก่าๆ จะย้ายตามไปในภายหลัง ตอนนี้ปิดการโพสต์กระทู้ไว้ เหลือไว้เฉพาะอ้างอิงเท่านั้น