有些網站,尤其是小成本網站,由於網站空間限制,我們不得不限制附件上傳,而現在,有了網盤附件後,我們大可不必使用 Discuz X2 自帶的附件上傳功能,本教程講述如何實現屏蔽 Discuz X2 的附件上傳按鈕。

首先屏蔽圖片附件上傳按鈕,打開網站模板文件 template/default/forum/post_editor_body.htm,搜索以下內容

  1. <a id="{$editorid}_image" title="{lang e_image_title}" menupos="00" menuwidth="600">{lang e_image}</a>

修改為

  1. <div
    style="display:none" id="HideImageUploading"><a
    id="{$editorid}_image" title="{lang e_image_title}" menupos="00"
    menuwidth="600">{lang e_image}</a></div>

然後,屏蔽附件上傳按鈕,繼續搜索以下內容

  1. <a id="{$editorid}_attach" title="{lang e_attach_title}" menupos="00" menuwidth="600">{lang e_attach}</a>

修改為

  1. <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 兩個文件中有相同的一段代碼,搜索以下代碼

  1. <!--{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>' : '');}-->

修改為

  1. <!--{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 目錄,在後台安裝插件即可。如果你的網站沒有提供網盤上傳功能,請務必不要屏蔽附件上傳功能,否則。