Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[已答复] DX门户模板中怎么样调用$todayposts、$onlinenum等这样的变量?

[复制链接]
lychee 发表于 2011-1-7 04:16:51 | 显示全部楼层 |阅读模式
问题描述
适用版本: Discuz! X1.5
浏览器: IE6 IE7 IE8 IE9 TT 360 IE10 firefox 其他(帖子中请注明浏览器) 
使用模板: 其他模板(请在回帖中说明模板的名称或者是模板的下载地址)
BUG地址: http://www.kuabai.com
大家都知道的 DX的门户模板中 是不可以加$todayposts、$onlinenum等这样的变量来调用今日发贴,在线会员数等功能的。
原因可能是因为模板中没有加载程序核心。
最近无意中发现了这个站,发现他的首页是可以调用的,好奇之下就查看了下他的门户模板源码,发现他加载了一个php文件、
http://www.xxx.com/template/19lou/portal/index.htm
就是这个地址的文件,在{subtemplate common/header}下还加载了
<!--{eval require_once DISCUZ_ROOT.'./source/include/portal/portal_19lou.php';}-->
这样一段代码,意思是在运行的时候加载一次portal_19lou.php这个文件,可能这个文件包含了$todayposts、$onlinenum这些变量的赋值语句吧,总之加载过这个文件后门户首页就可以调用在线会员、今日发贴、发帖总数等内容了。
大家谁买了这个模板?可不可以把这个php文件共享一份啊?或者有高手帮忙做一个啊。
cr180 发表于 2011-1-7 23:24:41 | 显示全部楼层
https://discuz.dismall.com/thread-1972461-1-1.html 借鉴一下该贴10楼朋友的回复吧
回复

使用道具 举报

tagsing 发表于 2011-1-23 17:52:45 | 显示全部楼层
我买了这个版子的 风格,可惜就三项,没有别 了、
http://www.tagsing.cn
回复

使用道具 举报

yushine 发表于 2011-1-26 16:01:54 | 显示全部楼层

随手写了一个。
请上传至source/module/forum
然后在你需要的模板页面引入
<!--{eval require_once DISCUZ_ROOT.'./source/module/forum/forum_vidu.php';}-->
就可以使用$todayposts、$onlinenum 这样的变量了。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

googolewang 发表于 2015-9-11 13:44:44 | 显示全部楼层
本帖最后由 googolewang 于 2015-9-11 13:48 编辑

<!--{eval
        $usernum = DB::result_first("SELECT count(*) FROM ".DB::table('common_member'));  //会员数
        $onlinenum = DB::result_first("SELECT count(*) FROM ".DB::table('common_session'));  //在线会员数
        $todayposts = DB::result_first("SELECT sum(todayposts) FROM ".DB::table('forum_forum')." WHERE status=1");  //今日发帖数
        $yesterdayposts = DB::result_first("SELECT sum(yesterdayposts) FROM ".DB::table('forum_forum')." WHERE status=1");  //昨日发帖数
        $posts = DB::result_first("SELECT sum(posts) FROM ".DB::table('forum_forum')." WHERE status=1");  //总帖子数
}-->
回复

使用道具 举报

googolewang 发表于 2015-9-11 13:46:17 | 显示全部楼层
本帖最后由 googolewang 于 2015-9-11 13:49 编辑

把上面的代码引入你要调用的页面头部,
<div id="chart" class="bm bw0 cl">
                <p class="chart z">今日: <em>$todayposts</em><span class="pipe">|</span>昨日: <em>$yesterdayposts</em><span class="pipe">|</span>帖子: <em>$posts</em><span class="pipe">|</span>会员: <em>$usernum</em></p>
                <div class="y">
                        <!--{hook/index_nav_extra}-->
                        <!--{if $_G['uid']}--><a href="forum.php?mod=guide&view=my" title="{lang my_posts}" class="xi2">{lang my_posts}</a><!--{/if}--><!--{if !empty($_G['setting']['search']['forum']['status'])}--><!--{if $_G['uid']}--><span class="pipe">|</span><!--{/if}--><a href="forum.php?mod=guide&view=new" title="{lang show_newthreads}" class="xi2">{lang show_newthreads}</a><!--{/if}-->
                </div>
        </div>

把这一段代码放到页面要显示的部分即可!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-5-2 19:11 , Processed in 0.110454 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表