这段代码如何加?

WBOY
Release: 2016-06-23 13:49:39
Original
1378 people have browsed it

本题是关于php做的cms管理系统discuz的问题,所以回答本题要搞过discuz的人.
问题是这样:我想把系统自带的尾部统计在线人数的代码放在头部,所以我就复制了这段代码到头部中,但是奇怪的是显示为乱码,起码以为是条件判断的原因,后来多次检查,感觉不是.
下面的代码我是我复制的,不知为啥放在head.htm中就是不行呢,应该如何写才是正确的呢?

<!--{if empty($gid) && $_G['setting']['whosonlinestatus']}-->			<div id="online" class="bm oll">				<div class="bm_h">				<!--{if $detailstatus}-->					<span class="o"><a href="forum.php?showoldetails=no#online" title="{lang spread}"><img src="{IMGDIR}/collapsed_no.gif" alt="{lang spread}" /></a></span>					<h3>						<strong><a href="home.php?mod=space&do=friend&view=online&type=member">{lang onlinemember}</a></strong>						<span class="xs1">- <strong>$onlinenum</strong> {lang onlines}						- <strong>$membercount</strong> {lang index_members}(<strong>$invisiblecount</strong> {lang index_invisibles}),						<strong>$guestcount</strong> {lang index_guests}						- {lang index_mostonlines} <strong>$onlineinfo[0]</strong> {lang on} <strong>$onlineinfo[1]</strong>.</span>					</h3>				<!--{else}-->					<!--{if empty($_G['setting']['sessionclose'])}-->						<span class="o"><a href="forum.php?showoldetails=yes#online" title="{lang spread}"><img src="{IMGDIR}/collapsed_yes.gif" alt="{lang spread}" /></a></span>					<!--{/if}-->					<h3>						<strong>							<!--{if !empty($_G['setting']['whosonlinestatus'])}-->								{lang onlinemember}							<!--{else}-->								<a href="home.php?mod=space&do=friend&view=online&type=member">{lang onlinemember}</a>							<!--{/if}-->						</strong>						<span class="xs1">- {lang total} <strong>$onlinenum</strong> {lang onlines}						<!--{if $membercount}-->- <strong>$membercount</strong> {lang index_members},<strong>$guestcount</strong> {lang index_guests}<!--{/if}-->						- {lang index_mostonlines} <strong>$onlineinfo[0]</strong> {lang on} <strong>$onlineinfo[1]</strong>.</span>					</h3>				<!--{/if}-->				</div>			<!--{if $_G['setting']['whosonlinestatus'] && $detailstatus}-->				<dl id="onlinelist" class="bm_c">					<dt class="ptm pbm bbda">$_G[cache][onlinelist][legend]</dt>					<!--{if $detailstatus}-->						<dd class="ptm pbm">						<ul class="cl">						<!--{if $whosonline}-->							<!--{loop $whosonline $key $online}-->								<li title="{lang time}: $online[lastactivity]">								<img src="{STATICURL}image/common/$online[icon]" alt="icon" />								<!--{if $online['uid']}-->									<a href="home.php?mod=space&uid=$online[uid]">$online[username]</a>								<!--{else}-->									$online[username]								<!--{/if}-->								</li>							<!--{/loop}-->						<!--{else}-->							<li   style="max-width:90%">{lang online_only_guests}</li>						<!--{/if}-->						</ul>					</dd>					<!--{/if}-->				</dl>			<!--{/if}-->			</div>		<!--{/if}-->
Copy after login


回复讨论(解决方案)

下图是复制上面代码后的结果

清缓存看看。

清缓存看看。


请缓存这是最起码的常识吧!

统计在线人数,那是首页的功能,如:$onlinenum,$invisiblecount等,都是在\source\module\forum\forum_index.php里面定义的
而header.htm是所有页面都要引用的,里面的变量都是在初始化的时候取出放到了$_G里面,所以,你直接copy的代码不生效
有两种办法:
1>在source\class\discuz\discuz_application.php中初始化的时候查询数据库,并放到$_G中(不建议新手这样做)
2>在header.htm中调用一个函数,如:,getnolineinfo()方法在source\function\function_core.php中自己定义,里面具体的实现代码,请参考source\module\forum\forum_index.php中178行左右的if里面的代码

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template