phpBB3
| เปิดลิ้งก์ในกระทู้ด้วยหน้าต่างเบราเซอร์ใหม่ |
|
|
|
| เขียนโดย Administrator |
| วันพฤหัสบดีที่ 06 พฤษภาคม 2010 เวลา 21:40 น. |
|
เวลาที่โพสต์ลิ้งก์ในกระทู้ phpBB3 เมื่อคลิ๊กที่ลิ้งก์ก็จะโหลดหน้าที่ลิ้งก์ไปหาขึ้นมา ด้วยหน้าต่างเบราเซอร์อันเดิม แต่อยากจะให้คุณอยู่กับเรานาน ๆ ต้องการให้เมื่อคลิ๊กลิ้งก์แล้วเปิดเป็นหน้าต่างเบราเซอร์อันใหม่ขึ้นมาหรือเป็นแท็บใหม่ขึ้นมา เหมือนใช้คำสั่ง TARGET="_blank" ใน html (ใช้ได้เฉพาะลิ้งก์ออกภายนอก) วันนี้มีวิธีครับ แก้ไขไฟล์เดียวจบ ใช้งานได้ ทดสอบบน phpBB 3.0.7-PL1 เปิดไฟล์ viewtopic.php หาบรรทัด
แล้วเพิ่มโค๊ดด้านล่าง ลงไปหลังบรรทัดด้านบน // BEGIN - OPEN LINKS IN NEW WINDOW MOD
// February 5th, 2010 By Liv Jones
//
// *Custom Variables:
// If your server variable isn't set you may need to replace
// this line with an example such as:
// $home_url=greensboring.com;
$home_url=$_SERVER['HTTP_HOST'];
// *Option Custom Variables:
// This is a White List of URLs
// other than yours you'd like to link to
$short_list=array(
'livjones.com',
'bbc.com',
);
// Disable First First Post DoFollow (default: enabled)
// To disable remove the commenting slashes in front of:
// $follow_fp='disable';
// ************ CHANGE NOTHING BELOW HERE ****************
// Make all the links the same format regardless of url tag
$message = preg_replace('/(a class="postlink" href="(.*?)")/','a href="$2" class="postlink"',$message);
// replace all links with nofollow
$message = preg_replace('/(class="postlink")/','class="postlink" rel="nofollow" onclick="window.open(this.href);return false;"',$message);
// parse out local links to remove nofollow
$message = preg_replace('/(a href="http:\/\/'.$home_url.'(.*?)" class="postlink" rel="nofollow" onclick="window.open\(this.href\)\;return false\;")/','a href="http://'.$home_url.'$2" class="postlink-local"',$message);
// DoFollow on First Post only like a blog
if (($row['post_id'] == $topic_data['topic_first_post_id']) && ($follow_fp != 'disable') && ($user_cache[$poster_id]['posts'] > 3)) {
$message = preg_replace('/(rel="nofollow")/','',$message);
}
// Licensing
$message = preg_replace(base64_decode('LyBHcmVlbnNib3JvIC8='),base64_decode('PGEgaHJlZj0iaHR0cDovL2dyZWVuc2JvcmluZy5jb20vIj4gR3JlZW5zYm9ybyA8L2E+'),$message);
// Optional WhiteList for dofollowing
// (But still open in new window)
foreach($short_list as $sl) {
$message = preg_replace('/(href="http:\/\/'.$sl.'(.*?)" class="postlink" rel="nofollow")/','href="http://'.$sl.'$2" class="postlink" rel="dofollow"',$message);
}
// Parsing Image Sizes
if ($row['post_id'] == $topic_data['topic_first_post_id']) {
$message = preg_replace('/(alt="Image")/','alt="Image" style="max-width:400px;"',$message); } else {
$message = preg_replace('/(alt="Image")/','alt="Image" style="max-width:650px;"',$message); }
// END - OPEN LINKS IN NEW WINDOW MODบันทึกไฟล์ จบครับใช้งานได้ทันที
|
| แก้ไขล่าสุด ใน วันเสาร์ที่ 08 พฤษภาคม 2010 เวลา 22:15 น. |







