forum กดชื่อกระทู้แล้วให้เปิดหน้าต่างใหม่

  • 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.

ตอนนี้ผมกำลังทำ forum อยู่ครับ ทีนี้ user อยากให้กดที่ชื่อกระทู้แล้วเปิดหน้าต่างใหม่
หาเท่าไหร่ก็หาไม่เจอว่าจะต้องไปแก้ตรงไหน
มีใครรู้วิธีช่วยผมด้วยครับ

mk's picture

โดยส่วนตัวผมเชื่อว่าผู้อ่านควรเป็นคนกำหนดพฤติกรรมของลิงก์และหน้าต่าง เราไม่ควรไปคิดแทนว่าจะเปิดหน้าใหม่แทนผู้อ่านหรือเปล่า

ผมก็เชื่อแบบนั้น
แต่เจ้าของเวบเค้าอยากได้แบบนี้อ่ะครับ
ปวดหัวเลย

sugree's picture

แก้ template.php โดยเพิ่มโค้ดข้างล่างลงไป

function phptemplate_forum_topic_list($tid, $topics, $sortby, $forum_per_page) {
  global $forum_topic_list_header;
  $rows = array();
  if ($topics) {
 
    foreach ($topics as $topic) {
      // folder is new if topic is new or there are new comments since last visit
      if ($topic->tid != $tid) {
        $rows[] = array(
          array('data' => theme('forum_icon', $topic->new, $topic->num_comments, $topic->comment_mode, $topic->sticky), 'class' => 'icon'),
          array('data' => check_plain($topic->title), 'class' => 'title'),
          array('data' => l(t('This topic has been moved'), "forum/$topic->tid"), 'colspan' => '3')
        );
      }
      else {
        $rows[] = array(
          array('data' => theme('forum_icon', $topic->new, $topic->num_comments, $topic->comment_mode, $topic->sticky), 'class' => 'icon'),
          array('data' => l($topic->title, "node/$topic->nid", array('target' => '_blank')), 'class' => 'topic'),
          array('data' => $topic->num_comments . ($topic->new_replies ? '<br />'. l(format_plural($topic->new_replies, '1 new', '@count new'), "node/$topic->nid", NULL, NULL, 'new') : ''), 'class' => 'replies'),
          array('data' => _forum_format($topic), 'class' => 'created'),
          array('data' => _forum_format(isset($topic->last_reply) ? $topic->last_reply : NULL), 'class' => 'last-reply')
        );
      }
    }
  }
 
  $output = theme('table', $forum_topic_list_header, $rows);
  $output .= theme('pager', NULL, $forum_per_page, 0);
 
  return $output;
}

ผมแค่เพิ่ม “, array('target' => '_blank')” เท่านั้นแหละ

ผมใช้วิธีเขียน funtcion l ขึ้นมาใหม่เป็น lx โดยใส่ target="_blank" ไว้เลยเวลา link ไหนจะ _blank ก็เรียก function lx นี้ เอิ๊กๆ แก้ปัญหาแบบกำปั้นทุกดินจริงๆ

เดี๋ยวผมเปลี่ยนมาใช้วิธีของคุณ sugree ดีกว่า
้ง่ายกว่าที่ผมทำเยอะเลย

ย้าย Codenone

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

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