代碼: 選擇全部
新裝了 phpbb3 rc 5 也發現有這樣的問題...
没有加 [url] 的 http://xxxxx 會用同一視窗...
加了 [url]xxxxx[/url] 才開新視窗...
已找了不少有關檔案嘗試修改.. 但失敗了...
版主: 版主管理群
phpbb2 預設 '超連結' 是以開啟新的視窗btxray 寫:請高手指點..代碼: 選擇全部
新裝了 phpbb3 rc 5 也發現有這樣的問題... 没有加 [url] 的 http://xxxxx 會用同一視窗... 加了 [url]xxxxx[/url] 才開新視窗... 已找了不少有關檔案嘗試修改.. 但失敗了...
Open links in a new window
by Jackal on 22 Jul 2007 08:58
Problem
As you know phpBB3 is now conforming to standards and as such this means posted links no longer open in a new window when clicked.
Solution
This is a revised version of my original change, this appears to work when used with long magic URI's and thus fixes the bugs seen in the earlier edit on this board and the one at easytutorials
Please note that only links made after the change will be affected by this. To get old links to work correctly you will need to edit and submit the posts that contain them. This is because the link formatting is applied to the link before it is submitted to the database and thus any changes to the link format will not be in place on existing links.
Open includes/functions.php
Find:(line 2739)
Code: Select all代碼: 選擇全部
$html = "$whitespace<!-- $tag --><a$class href=\"$url\">$text</a><!-- $tag -->$append";
Replace With:
Code: Select all代碼: 選擇全部
$html = "$whitespace<!-- $tag --><a$class target=\"_blank\" href=\"$url\">$text</a><!-- $tag -->$append";
Find:(line 3427)
Code: Select all代碼: 選擇全部
case 'bbcode_htm': return array( '#<!\-\- e \-\-><a href="mailto:(.*?)">.*?</a><!\-\- e \-\->#', '#<!\-\- l \-\-><a (?:class="[\w-]+" )?href="(.*?)(?:(&|\?)sid=[0-9a-f]{32})?">.*?</a><!\-\- l \-\->#', '#<!\-\- ([mw]) \-\-><a (?:class="[\w-]+" )?href="(.*?)">.*?</a><!\-\- \1 \-\->#', '#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '#<!\-\- .*? \-\->#s', '#<.*?>#s', );
Replace With:
Code: Select all代碼: 選擇全部
case 'bbcode_htm': return array( '#<!\-\- e \-\-><a href="mailto:(.*?)">.*?</a><!\-\- e \-\->#', '#<!\-\- l \-\-><a (?:class="[\w-]+" target="[\w-]+" )?href="(.*?)(?:(&|\?)sid=[0-9a-f]{32})?">.*?</a><!\-\- l \-\->#', '#<!\-\- ([mw]) \-\-><a (?:class="[\w-]+" target="[\w-]+" )?href="(.*?)">.*?</a><!\-\- \1 \-\->#', '#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '#<!\-\- .*? \-\->#s', '#<.*?>#s', );
代碼: 選擇全部
'#<!\-\- ([mw]) \-\-><a (?:class="[\w-]+" )?href="(.*?)">.*?</a><!\-\- \1 \-\->#',
代碼: 選擇全部
'#<!\-\- ([mw]) \-\-><a (?:class="[\w-]+" (?:target="[\w-]+" )?)?href="(.*?)">.*?</a><!\-\- \1 \-\->#',
莫非您還在使用 <RC5 的版本?6yo.org 寫:幫補一下
Open includes/functions.php
Find:(line 2739)
的下一行也應該要一起改為代碼: 選擇全部
'#<!\-\- ([mw]) \-\-><a (?:class="[\w-]+" )?href="(.*?)">.*?</a><!\-\- \1 \-\->#',
如果要再考慮舊版的也要處理,新加的部份包括他上一行其實應該以 (?:新加的)? 夾住代碼: 選擇全部
'#<!\-\- ([mw]) \-\-><a (?:class="[\w-]+" (?:target="[\w-]+" )?)?href="(.*?)">.*?</a><!\-\- \1 \-\->#',
1. 我猜想會多了 'onclick="window.open(this.href);' 這段.6yo.org 寫:我是用3.0.0版,不過我沒有注意到版本的差別
已經按照那篇文章改過了
想做個確定,這樣改完後,DB內儲存的data是否會多
onclick="window.open(this.href);
這段?
這些改完有點擔心以後轉移等等會留下不好的伏筆,雖然還很久遠
另一個問題是,上面的語法跟target="_blank"間有什麼差異嗎?
代碼: 選擇全部
case 'bbcode_htm':
return array(
'#<!\-\- e \-\-><a href="mailto:(.*?)">.*?</a><!\-\- e \-\->#',
'#<!\-\- l \-\-><a (?:class="[\w-]+" )?href="(.*?)(?:(&|\?)sid=[0-9a-f]{32})?"(?: onclick="window\.open\(this\.href\);return false;")?>.*?</a><!\-\- l \-\->#',
'#<!\-\- ([mw]) \-\-><a (?:class="[\w-]+" )?href="(.*?)"(?: onclick="window\.open\(this\.href\);return false;")?>.*?</a><!\-\- \1 \-\->#',
'#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/.*? \/><!\-\- s\1 \-\->#',
'#<!\-\- .*? \-\->#s',
'#<.*?>#s',
);
嗯! XHTML 1.0 對於空字元的判斷比較嚴格.6yo.org 寫:我確定DB會因為這樣改,會出現 onclick這段,當然之前那樣改也是會出現target這段。
還蠻希望只改變我們解讀的方式就好,而不是去動到他原本要儲存的資訊。
我改完之後新舊都是沒有問題,應該是我新多的pattern會加上(?:NEW_ADD_PATTERN)? 夾住,就可以同時支援有無此mod的情況
include/functions.php代碼: 選擇全部
case 'bbcode_htm': return array( '#<!\-\- e \-\-><a href="mailto:(.*?)">.*?</a><!\-\- e \-\->#', '#<!\-\- l \-\-><a (?:class="[\w-]+" )?href="(.*?)(?:(&|\?)sid=[0-9a-f]{32})?"(?: onclick="window\.open\(this\.href\);return false;")?>.*?</a><!\-\- l \-\->#', '#<!\-\- ([mw]) \-\-><a (?:class="[\w-]+" )?href="(.*?)"(?: onclick="window\.open\(this\.href\);return false;")?>.*?</a><!\-\- \1 \-\->#', '#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '#<!\-\- .*? \-\->#s', '#<.*?>#s', );