有些網站,尤其是小成本網站,由於網站空間限制,我們不得不限制附件上傳,而現在,有了網盤附件後,我們大可不必使用 Discuz X2 自帶的附件上傳功能,本教程講述如何實現遮蔽 Discuz X2 的附件上傳按鈕。
首先遮蔽圖片附件上傳按鈕,開啟網站模板檔案 template/default/forum/post_editor_body.htm,搜尋以下內容
- <a id="{$editorid}_image" title="{lang e_image_title}" menupos="00" menuwidth="600">{lang e_image}</a>
修改為
- <div
style="display:none" id="HideImageUploading"><a
id="{$editorid}_image" title="{lang e_image_title}" menupos="00"
menuwidth="600">{lang e_image}</a></div>
然後,遮蔽附件上傳按鈕,繼續搜尋以下內容
- <a id="{$editorid}_attach" title="{lang e_attach_title}" menupos="00" menuwidth="600">{lang e_attach}</a>
修改為
- <div
style="display:none" id="HideImageUploading"><a
id="{$editorid}_image" title="{lang e_image_title}" menupos="00"
menuwidth="600">{lang e_image}</a></div>
到這裡,發帖視窗的工具條上的附件上傳按鈕已經不見了,我們還需要遮蔽快速發帖和快速回帖中的附件上傳按鈕。
在 template/default/forum/viewthread_fastpost.htm 和 template/default/forum/forumdisplay_fastpost.htm 兩個檔案中有相同的一段程式碼,搜尋以下程式碼
- <!--{eval $seditor =
array('fastpost', array('bold', 'color', 'img', 'link', 'quote',
'code', 'smilies'), !$_G['uid'] ? 1 : 0, $allowpostattach ? '<span
>|</span><span >{lang
e_attach_title}</span>' : '');}-->
修改為
- <!--{eval
$seditor = array('fastpost', array('bold', 'color', 'img', 'link',
'quote', 'code', 'smilies'), !$_G['uid'] ? 1 : 0, $allowpostattach ?
'<span >|</span><span
onclick=javascript:window.alert("要上傳附件請進入高階模式
然後在頁面左下方點選上傳網盤附件
不受格
式和檔案大小限制哦, 親!") >{lang e_attach_title}</span>' :
'');}-->
(以上網站模板程式碼只是舉例,當使用者點選上傳時會彈出資訊,提示使用網盤上傳附件,你可根據實現情況修改為其他的動作。)
注意,如果以上.htm 檔案裡面有中文字元且你使用的 Discuz 是 UTF-8 版,請將檔案另存為 UTF-8 編碼後再上傳,否則顯示出來會亂碼,最簡單的方法可以是: 用記事本開啟網頁檔案,檔案--另存為--編碼--UTF-8.
附件提供網盤上傳外掛,將附件解壓到 source/plugin 目錄,在後臺安裝外掛即可。如果你的網站沒有提供網盤上傳功能,請務必不要遮蔽附件上傳功能,否則。