Discuz设置编辑器标签仅对已登录用户显示

在模板文件夹中找到 viewthread.htm 和 viewthread_node.htm,PC版在/template/default/forum/viewthread.htm中找<div class=”pct”>标签,在后边添加如下代码:

<!--{if $_G['uid']}-->
 <!-- 用户未登录,移除相关标签内容 -->
   <!--{eval $post['message'] = preg_replace('/\[aplayer\].*?\[\/aplayer\]/is', '', $post['message']);}-->
   <!--{eval $post['message'] = preg_replace('/\[music\].*?\[\/music\]/is', '', $post['message']);}-->
<!--{else}-->
  <!-- 用户已登录,显示播放器内容 -->
  <meting-js server="__SERVER__" type="song" id="__SONGID__" lrc-type="0"></meting-js>
  <div id="songUrl" style="display: none;">{1}</div>
  <script src="/static/js/player/music.js" defer></script>
  <div id="aplayer"></div>
  <span id="musicurl" style="display: none;">{1}</span>
  <script src="/static/js/music/getmusic.js" defer></script>
<!--{/if}-->

修改后的整体代码如下:

		<div class="pct">
			<!--{ad/thread/a_pt/2/$postcount}-->
			<!--{if empty($ad_a_pr_css)}-->
				<style type="text/css">.pcb{margin-right:0}</style>
				<!--{eval $ad_a_pr_css=1;}-->
			<!--{/if}-->

			<!--{if !$post['first'] && $post['replycredit'] > 0}-->
				<div class="cm">
					<h3 class="psth xs1"><span class="icon_ring vm"></span>
						{lang replycredit} <span class="xw1 xs2 xi1">+{$post['replycredit']}</span> {$_G['setting']['extcredits'][$_G['forum_thread']['replycredit_rule']['extcreditstype']][unit]}{$_G['setting']['extcredits'][$_G['forum_thread']['replycredit_rule']['extcreditstype']][title]}
					</h3>
				</div>
			<!--{/if}-->
			
			<!--{if $_G['uid']}-->
   			 <!-- 用户未登录,移除相关标签内容 -->
 			   <!--{eval $post['message'] = preg_replace('/\[aplayer\].*?\[\/aplayer\]/is', '', $post['message']);}-->
 			   <!--{eval $post['message'] = preg_replace('/\[music\].*?\[\/music\]/is', '', $post['message']);}-->
			<!--{else}-->
  			  <!-- 用户已登录,显示播放器内容 -->
  			  <meting-js server="__SERVER__" type="song" id="__SONGID__" lrc-type="0"></meting-js>
  			  <div id="songUrl" style="display: none;">{1}</div>
  			  <script src="/static/js/player/music.js" defer></script>
  			  <div id="aplayer"></div>
  			  <span id="musicurl" style="display: none;">{1}</span>
  			  <script src="/static/js/music/getmusic.js" defer></script>
			<!--{/if}-->

			<!--{subtemplate forum/viewthread_node_body}-->
		</div>

 

移动版在/template/default/touch/forum/viewthread.htm中找到<div class=”message”>标签,在后边添加如下代码:

<!--{if $_G['uid']}-->
 <!-- 用户未登录,移除相关标签内容 -->
   <!--{eval $post['message'] = preg_replace('/\[aplayer\].*?\[\/aplayer\]/is', '', $post['message']);}-->
   <!--{eval $post['message'] = preg_replace('/\[music\].*?\[\/music\]/is', '', $post['message']);}-->
<!--{else}-->
  <!-- 用户已登录,显示播放器内容 -->
  <meting-js server="__SERVER__" type="song" id="__SONGID__" lrc-type="0"></meting-js>
  <div id="songUrl" style="display: none;">{1}</div>
  <script src="/static/js/player/music.js" defer></script>
  <div id="aplayer"></div>
  <span id="musicurl" style="display: none;">{1}</span>
  <script src="/static/js/music/getmusic.js" defer></script>
<!--{/if}-->

修改后的整体代码如下:

			<div class="message">
			    
		    	<!--{if $_G['uid']}-->
   		    	 <!-- 用户未登录,移除相关标签内容 -->
 		    	   <!--{eval $post['message'] = preg_replace('/\[aplayer\].*?\[\/aplayer\]/is', '', $post['message']);}-->
 		    	   <!--{eval $post['message'] = preg_replace('/\[music\].*?\[\/music\]/is', '', $post['message']);}-->
		    	<!--{else}-->
  		    	  <!-- 用户已登录,显示播放器内容 -->
  		    	  <meting-js server="__SERVER__" type="song" id="__SONGID__" lrc-type="0"></meting-js>
  		    	  <div id="songUrl" style="display: none;">{1}</div>
  	    		  <script src="/static/js/player/music.js" defer></script>
  	    		  <div id="aplayer"></div>
  	    		  <span id="musicurl" style="display: none;">{1}</span>
  	       		  <script src="/static/js/music/getmusic.js" defer></script>
			    <!--{/if}-->
			    
				<!--{if $post['warned']}-->
					<span class="quote">{lang warn_get}</span>
				<!--{/if}-->
				<!--{if !$post['first'] && !empty($post['subject']) && (!$needhiddenreply)}-->
					<h2><strong>$post['subject']</strong></h2>
				<!--{/if}-->
				<!--{if $_G['adminid'] != 1 && $_G['setting']['bannedmessages'] & 1 && (($post['authorid'] && !$post['username']) || ($post['groupid'] == 4 || $post['groupid'] == 5) || $post['status'] == -1 || $post['memberstatus'])}-->
					<div class="quote">{lang message_banned}</div>
				<!--{elseif $_G['adminid'] != 1 && $post['status'] & 1}-->
					<div class="quote">{lang message_single_banned}</div>
				<!--{elseif $needhiddenreply}-->
					<div class="quote">{lang message_ishidden_hiddenreplies}</div>
				<!--{elseif $post['first'] && $_G['forum_threadpay']}-->
					<!--{template forum/viewthread_pay}-->
				<!--{else}-->
					<!--{if $_G['setting']['bannedmessages'] & 1 && (($post['authorid'] && !$post['username']) || ($post['groupid'] == 4 || $post['groupid'] == 5))}-->
						<div class="quote">{lang admin_message_banned}</div>
					<!--{elseif $post['status'] & 1}-->
						<div class="quote">{lang admin_message_single_banned}</div>
					<!--{/if}-->
					<!--{if $post['first'] && $_G['forum_thread']['price'] > 0 && $_G['forum_thread']['special'] == 0}-->
						{lang pay_threads}: <strong>$_G['forum_thread']['price'] {$_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['unit']}{$_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['title']} </strong> <a href="forum.php?mod=misc&action=viewpayments&tid=$_G['tid']" >{lang pay_view}</a>
					<!--{/if}-->
					<!--{if $post['first'] && $threadsort && $threadsortshow}-->
						<!--{if $threadsortshow['optionlist'] && !($post['status'] & 1) && !$_G['forum_threadpay']}-->
							<!--{if $threadsortshow['optionlist'] == 'expire'}-->
								{lang has_expired}
							<!--{else}-->
								<div class="box_ex2 viewsort b_b mb10">
									<h4>$_G['forum']['threadsorts']['types'][$_G['forum_thread']['sortid']]</h4>
								<!--{loop $threadsortshow['optionlist'] $option}-->
									<!--{if $option['type'] != 'info'}-->
										$option['title']: <!--{if $option['value']}-->$option['value'] $option['unit']<!--{else}--><span class="fc-s">--</span><!--{/if}--><br />
									<!--{/if}-->
								<!--{/loop}-->
								</div>
							<!--{/if}-->
						<!--{/if}-->
					<!--{/if}-->
					<!--{if $post['first']}-->
						<!--{if !$_G['forum_thread']['special']}-->
							$post['message']
						<!--{elseif $_G['forum_thread']['special'] == 1}-->
							<!--{template forum/viewthread_poll}-->
						<!--{elseif $_G['forum_thread']['special'] == 2}-->
							<!--{template forum/viewthread_trade}-->
						<!--{elseif $_G['forum_thread']['special'] == 3}-->
							<!--{template forum/viewthread_reward}-->
						<!--{elseif $_G['forum_thread']['special'] == 4}-->
							<!--{template forum/viewthread_activity}-->
						<!--{elseif $_G['forum_thread']['special'] == 5}-->
							<!--{template forum/viewthread_debate}-->
						<!--{elseif $threadplughtml}-->
							$threadplughtml
							$post['message']
						<!--{else}-->
							$post['message']
						<!--{/if}-->
					<!--{else}-->
						$post['message']
					<!--{/if}-->
				<!--{/if}-->
			</div>

刷新缓存,就可以了。

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注