立即註冊  找回密码

QQ登录

只需一步,快速开始

开启辅助访问 切换到宽版

東里論壇

搜索
查看: 8160|回复: 0

[使用心得] 让Discuz!论坛帖子广告位在帖子正文右方呆着

[复制链接]

335

主题

486

帖子

3089

积分

管理員

Rank: 9Rank: 9Rank: 9

积分
3089
发表于 2015-8-2 02:06:19 |阅读模式
Discuz! X论坛可以自己添加论坛帖内广告,有三个位置,上下右各一。不过,右边的广告位,和正文是在同一<DIV>里面的,当你在右边添加广告,而帖子内容文字够多时,文字就会绕行,让出了广告位置。不过,我有点强迫症,喜欢让广告位与正文不互相影响,而正文看起来整整齐齐的,所以自己动手修改了模板。

修改template\default\forum\viewthread_node_body.htm

找到以下代码:
  1.                                 <table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_$post[pid]">
  2.                                 <!--{if !$_G['inajax']}-->
  3.                                         <!--{if $ad_a_pr}-->
  4.                                                 $ad_a_pr
  5.                                         <!--{/if}-->
  6.                                 <!--{/if}-->
  7.                                 <!--{if !empty($_G['setting']['guesttipsinthread']['flag']) && empty($_G['uid']) && !$post['attachment'] && $_GET['from'] != 'preview'}-->
  8.                                 <div class="attach_nopermission attach_tips">
  9.                                         <div>
  10.                                                 <h3><strong>
  11.                                                                 <!--{if !empty($_G['setting']['guesttipsinthread']['text'])}-->
  12.                                                                 {$_G['setting']['guesttipsinthread']['text']}
  13.                                                                 <!--{else}-->
  14.                                                                 {lang guesttipsinthread_text}
  15.                                                                 <!--{/if}-->
  16.                                                         </strong></h3>
  17.                                                 <p>{lang attach_nopermission_login} <!--{hook/global_login_text}--></p>
  18.                                         </div>
  19.                                         <span class="atips_close" onclick="this.parentNode.style.display='none'">x</span>
  20.                                 </div>
  21.                                 <!--{/if}-->
  22.                                 $post[message]</td></tr></table>
复制代码

修改为:
  1.                                 <table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_$post[pid]">
  2.                                 <!--{if !empty($_G['setting']['guesttipsinthread']['flag']) && empty($_G['uid']) && !$post['attachment'] && $_GET['from'] != 'preview'}-->
  3.                                 <div class="attach_nopermission attach_tips">
  4.                                         <div>
  5.                                                 <h3><strong>
  6.                                                                 <!--{if !empty($_G['setting']['guesttipsinthread']['text'])}-->
  7.                                                                 {$_G['setting']['guesttipsinthread']['text']}
  8.                                                                 <!--{else}-->
  9.                                                                 {lang guesttipsinthread_text}
  10.                                                                 <!--{/if}-->
  11.                                                         </strong></h3>
  12.                                                 <p>{lang attach_nopermission_login} <!--{hook/global_login_text}--></p>
  13.                                         </div>
  14.                                         <span class="atips_close" onclick="this.parentNode.style.display='none'">x</span>
  15.                                 </div>
  16.                                 <!--{/if}-->
  17.                                 $post[message]</td>
  18.                                 <td style="vertical-align:top;width:130px;"><!--{if !$_G['inajax']}-->
  19.                                                 <!--{if $ad_a_pr}-->
  20.                                                         $ad_a_pr
  21.                                                 <!--{/if}-->
  22.                                 <!--{/if}--></td></tr></table>
复制代码

简单地说,就是增加一个<td>,并设置好他的宽度(我设置为130px,这样就只能添加宽度为120px以内的广告框。),然后将获取帖内右侧广告的代码移进去。

上面的是主楼的代码,下面还有一段回复楼的代码,修改原理相同,找到:
  1.                         <table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_$post[pid]">
  2.                         <!--{if !$_G['inajax']}-->
  3.                                 <!--{if $ad_a_pr}-->
  4.                                         $ad_a_pr
  5.                                 <!--{/if}-->
  6.                         <!--{/if}-->
  7.                         <!--{if $post['invisible'] != '-2' || $_G['forum']['ismoderator']}-->$post[message]<!--{else}--><span class="xg1">{lang moderate_need}</span><!--{/if}--></td></tr></table>
复制代码

修改为:
  1.                         <table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_$post[pid]">
  2.                         <!--{if $post['invisible'] != '-2' || $_G['forum']['ismoderator']}-->$post[message]<!--{else}--><span class="xg1">{lang moderate_need}</span><!--{/if}--></td>
  3.                         <td style="vertical-align:top;width:130px;"><!--{if !$_G['inajax']}-->
  4.                                                 <!--{if $ad_a_pr}-->
  5.                                                         $ad_a_pr
  6.                                                 <!--{/if}-->
  7.                                 <!--{/if}--></td></tr></table>
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即註冊

本版积分规则

QQ|网站地图|小黑屋|Archiver|東里論壇 ( 粤ICP备14015598号 ) 公安备案图标粤公网安备 44512202000019号
GMT+8, 2024-4-25 12:43 , Processed in 0.112600 second(s), 45 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.