discuz 把主帖背景作为body背景
默认情况下,帖子设置楼层背景只限于本楼层,现在我要将它改为:当主帖设置了背景,就把这个背景作为整个页面(body)的背景,回复楼层不变,依然是局限于自己楼层。
完整经过:
1.获得主题帖背景图。
在主帖设置好背景图后,会在帖子内容字段“message”中存储一段如“[ postbg]bg5.png[ /postbg]”的标签,系统处理之后将它变成了
$_G['forum_posthtml']['header'][$post[pid]]
复制代码
这句在viewthread_node_body.htm里,会生成一段样式代码,例如
<style type="text/css">#pid1498{background-image:url("static/image/postbg/bg1.png");}</style>
复制代码
图片地址看到了,但需要提取下才能拿出来用。
2.把样式代码中的图片提取出来。
正则提取语句
<!--{eval $mage_match=preg_match("|background-image:url\((.*)\);|U", $_G['forum_posthtml']['header'][$post[pid]], $result);}-->
复制代码
$result是个数组,两项:
$result[0]是background-image:url("static/image/postbg/bg1.png");
$result[1]是"static/image/postbg/bg1.png"
完整的代码,这里以$result[1]为例,可在viewthread_node_body.htm里顶部加一段
<!--{if $post['first']}-->
<!--{eval $mage_match=preg_match("|background-image:url\((.*)\);|U", $_G['forum_posthtml']['header'][$post[pid]], $result);}-->
<style>body{ {$result[0]} }</style>
<!--{/if}-->
复制代码
意思是,如果是主帖,body使用提取出来的主帖楼层背景。
3.把主帖楼层里的背景去掉
在viewthread_node_body.htm里查找
$_G['forum_posthtml']['header'][$post[pid]]
复制代码
给它套上判断,即
<!--{if !$post['first']}-->$_G['forum_posthtml']['header'][$post[pid]]<!--{/if}-->
复制代码
帖子背景在回复帖生效。
end。
* 如果出现设置过帖子背景后,再编辑时,编辑器无法切换可视化、部分按钮失效的情况,打开/template/default/common/editor.htm,顶部的
<script type="text/javascript" src="{$_G['setting']['jspath']}common_postimg.js?{VERHASH}"></script>
复制代码
改为
<script type="text/javascript" src="data/cache/common_postimg.js?{VERHASH}"></script>
复制代码
X3.4版本没有这句,加上就行了,这是自带问题,与俺无关,详情请访问官方论坛查询。
完整经过:
1.获得主题帖背景图。
在主帖设置好背景图后,会在帖子内容字段“message”中存储一段如“[ postbg]bg5.png[ /postbg]”的标签,系统处理之后将它变成了
$_G['forum_posthtml']['header'][$post[pid]]
复制代码
这句在viewthread_node_body.htm里,会生成一段样式代码,例如
<style type="text/css">#pid1498{background-image:url("static/image/postbg/bg1.png");}</style>
复制代码
图片地址看到了,但需要提取下才能拿出来用。
2.把样式代码中的图片提取出来。
正则提取语句
<!--{eval $mage_match=preg_match("|background-image:url\((.*)\);|U", $_G['forum_posthtml']['header'][$post[pid]], $result);}-->
复制代码
$result是个数组,两项:
$result[0]是background-image:url("static/image/postbg/bg1.png");
$result[1]是"static/image/postbg/bg1.png"
完整的代码,这里以$result[1]为例,可在viewthread_node_body.htm里顶部加一段
<!--{if $post['first']}-->
<!--{eval $mage_match=preg_match("|background-image:url\((.*)\);|U", $_G['forum_posthtml']['header'][$post[pid]], $result);}-->
<style>body{ {$result[0]} }</style>
<!--{/if}-->
复制代码
意思是,如果是主帖,body使用提取出来的主帖楼层背景。
3.把主帖楼层里的背景去掉
在viewthread_node_body.htm里查找
$_G['forum_posthtml']['header'][$post[pid]]
复制代码
给它套上判断,即
<!--{if !$post['first']}-->$_G['forum_posthtml']['header'][$post[pid]]<!--{/if}-->
复制代码
帖子背景在回复帖生效。
end。
* 如果出现设置过帖子背景后,再编辑时,编辑器无法切换可视化、部分按钮失效的情况,打开/template/default/common/editor.htm,顶部的
<script type="text/javascript" src="{$_G['setting']['jspath']}common_postimg.js?{VERHASH}"></script>
复制代码
改为
<script type="text/javascript" src="data/cache/common_postimg.js?{VERHASH}"></script>
复制代码
X3.4版本没有这句,加上就行了,这是自带问题,与俺无关,详情请访问官方论坛查询。
上一篇:DIY加入随机调用修改方法
免责声明:本站所有文章和图片均来自用户分享和网络收集,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服处理。
热门教程
discuz电脑版、手机版去除标题title中的PoweredbyDisc2018-12-27
Discuz 触屏手机版支持视频播放的方法2018-12-27
discuz手机版支持视频播放的修改方法2018-12-27
Discuz! 程序 X3.2、X3.3升级3.4教程2018-12-27
discuz X3以及X3.4论坛搬家完美详细教程2019-01-02
怎么开启手机版2018-12-25
去掉Discuz论坛底部的Powered 等版权信息2018-12-27
discuz! x3.4插件位置DZ论坛X3版本插件在哪个文件夹?2018-12-26
Mysql修改端口号后织梦dedecms的修改方法2018-12-27
Discuz!X3.2论坛实现全站HTTPS终极方法教程2018-12-28