[問題]關於強制使用主題類型

phpBB 2 MOD Support
無論是官方或非官方認證之外掛,安裝與使用問題討論。
(發表文章請按照公告格式發表,違者砍文)

版主: 版主管理群

主題已鎖定
依夢兒
竹貓忠實會員
竹貓忠實會員
文章: 2013
註冊時間: 2002-11-20 00:07

[問題]關於強制使用主題類型

文章 依夢兒 »

問題外掛:強制主題類型 & Hide subject field on reply
使用版本:phpBB 2.0.10
狀況描述:

強制使用主題類型:http://phpbb-tw.net/phpbb/viewtopic.php?t=18110
Hide subject field on reply:

代碼: 選擇全部

###############################################
##   Hack Title:   Hide subject field on reply.
##   Hack Version:   1.0.1
##   Author:      Antony Bailey
##   Description:   Hides the subject field in posting a reply.
##   Compatibility:   2.0.4
##
##   Installation Level: Easy
##   Installation Time: 5 minutes
##   Files To Edit: 3
##      posting.php
##      privmsgs.php
##	posting_body.tpl
##
##   History:
##      1.0.0:    Started, and blocked in posting.
##      1.0.1:    Found and corrected a bug in Private Messaging.
##
##   Author Notes:
##      The field is un-needed imho.
##	The error, with PM's has been fixed, it made it impossible to send a message.
##	I wrote this mainly for my forums, but decided to share it as there are like minded people out there.
##	Also just another hack, for the list. Gona get to 1500 downloads soon, Patrick.
##
##   Support:      http://www.phpbbhacks.com/forums
##   Copyright:      ?003 Hide subject field on reply 1.0.1 - Antony Bailey
##
###############################################
##   You downloaded this hack from phpBBHacks.com, the #1 source for phpBB related downloads.
##   Please visit http://www.phpbbhacks.com/forums for support.
###############################################
##
###############################################
##   This hack is released under the GPL License.
##   This hack can be freely used, but not distributed, without permission.
##   Intellectual Property is retained by the hack author(s) listed above.
###############################################
#
#-----[ OPEN ]------------------------------------------
#
posting.php

#
#-----[ FIND ]------------------------------------------
#
	$template->assign_block_vars('switch_type_toggle', array());
#
#-----[ AFTER, ADD ]------------------------------------------
#

	$template->assign_block_vars('switch_allow_subject_on', array());

#
#-----[ OPEN ]------------------------------------------
#
privmsg.php

#
#-----[ FIND ]------------------------------------------
#
	$template->assign_block_vars('switch_privmsg', array());
#
#-----[ AFTER, ADD ]------------------------------------------
#

	$template->assign_block_vars('switch_allow_subject_on', array());

#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/posting_body.tpl

#
#-----[ FIND ]------------------------------------------
#
	<tr>
	  <td class="row1" width="22%"><span class="gen"><b>{L_SUBJECT}</b></span></td>
	  <td class="row2" width="78%"> <span class="gen">
		<input type="text" name="subject" size="45" maxlength="60" style="width:450px" tabindex="2" class="post" value="{SUBJECT}" />
		</span> </td>
	</tr>
#
#-----[ REPLACE, WITh ]------------------------------------------
#
   	<!-- BEGIN switch_allow_subject_on -->
	<tr>
	  <td class="row1" width="22%"><span class="gen"><b>{L_SUBJECT}</b></span></td>
	  <td class="row2" width="78%"> <span class="gen">
		<input type="text" name="subject" size="45" maxlength="60" style="width:450px" tabindex="2" class="post" value="{SUBJECT}" />
		</span> </td>
	</tr>
  	<!-- END switch_allow_subject_on -->
#
#-----[ SAVE & CLOSE ALL FILES ]------------------------------------------
#
# End
安裝了這二支外掛,結果發現有一個後遺症。
就是回覆文章的時候,因為 Hide subject field on reply 外掛把主題名稱的輸入欄位給隱藏起來,
而強制使用主題類型外掛的 Java scipt 找不到 document.post.subject.value ,於是會跳出瀏覽器的錯誤碼。
沒辦法,我只好把強制使用主題類型外掛給拆掉,結果開始有網友發表主題的時候不加上主題類型.... Orz

後來想到一個解決方法,就是把強制使用主題類型改寫入 functions_post.php 內,
這樣只有網友在發表主題($mode == 'newtopic')的時候,系統才會去檢查有沒有加上主題類型。
如果是回覆文章的時候,系統不會去檢查有沒有加上主題類型,也就不會和 Hide subject field on reply 外掛相衝了。

我試過這樣修改:

代碼: 選擇全部

開啟 functions_post.php ,搜尋:

// Check message

上面加入:

	if ($mode == 'newtopic' && $subject != '[')
	{
		$error_msg .= (!empty($error_msg)) ? '<br />' . $lang['Empty_subject_type'] : $lang['Empty_subject_type'];\r
	}

開啟 lang_main.php ,加入:

$lang['Empty_subject_type'] = '發表主題必須選擇主題類型';
不過結果是失敗的....

如果有人知道要怎麼樣把強制使用主題類型改寫到 functions_post.php 內,煩請指教一下,謝謝。
有任何關於 phpBB 或是架站的問題,請在論壇上公開發表出來,大家一起討論。
請不要丟私人訊息問我,因為私訊是用來聊私事的。
這樣作對於解決您的問題一點幫助也沒有,也很沒有效率,小弟我一概謝絕。



搜尋是一種美德,在發問之前,請多加利用頂端的文章搜尋功能,搜尋可能的關鍵字。
確定您想問的問題找不到答案後,再發問。
~倉木麻衣~
竹貓忠實會員
竹貓忠實會員
文章: 1405
註冊時間: 2004-03-21 21:00

文章 ~倉木麻衣~ »

代碼: 選擇全部

	if ($mode == 'newtopic' && $subject != '[')
這樣子的話...只要subject不要剛好是[
不論是否有主題類型~都會被判定為沒有主題類型~

個人認為應該要判斷subject的開頭是否為[ 比較恰當\r
且應該要忽略開頭可能出現的空白字元(像是 " [測試]test")
這個可以用regular expression function來解決
試看看底下的作法~應該可行
注意(\s| )裡的空白為全型空白\r

代碼: 選擇全部

	if ($mode == 'newtopic' && [color=blue]!preg_match("/^(\s| )*\[/",$subject)[/color] )
依夢兒
竹貓忠實會員
竹貓忠實會員
文章: 2013
註冊時間: 2002-11-20 00:07

文章 依夢兒 »

~倉木麻衣~ 寫:個人認為應該要判斷subject的開頭是否為[ 比較恰當\r
且應該要忽略開頭可能出現的空白字元(像是 " [測試]test")
對,應該要這樣作,是我表達能力不太好,沒有說清楚....^^"

剛剛試了一下,可以達到我要的效果了,謝謝你提供的方法。
(又學到一個 php 的寫法了^^)
有任何關於 phpBB 或是架站的問題,請在論壇上公開發表出來,大家一起討論。
請不要丟私人訊息問我,因為私訊是用來聊私事的。
這樣作對於解決您的問題一點幫助也沒有,也很沒有效率,小弟我一概謝絕。



搜尋是一種美德,在發問之前,請多加利用頂端的文章搜尋功能,搜尋可能的關鍵字。
確定您想問的問題找不到答案後,再發問。
主題已鎖定

回到「外掛問題討論」