如何在discuz的discuz.htm中调用当前登陆用户的主题、各项积分等信息
程序员文章站
2022-06-06 19:44:36
...
如何在discuz的discuz.htm中调用当前登陆用户的主题、各项积分等信息
目前已知的只有:$_G['member'][credits] 是当前用户的积分
不行啊
而且在输出的位置调用变量 输出值是空
Array
(
[1] => Array
(
[img] =>
[title] => 威望
[unit] =>
[ratio] => 0
[showinthread] =>
[allowexchangein] =>
[allowexchangeout] =>
[num] => 0
)
[2] => Array
(
[img] =>
[title] => 金钱
[unit] =>
[ratio] => 0
[showinthread] =>
[allowexchangein] =>
[allowexchangeout] =>
[num] => 25
)
[3] => Array
(
[img] =>
[title] => 贡献
[unit] =>
[ratio] => 0
[showinthread] =>
[allowexchangein] =>
[allowexchangeout] =>
[num] => 0
)
)
Array
(
[1] => Array
(
[img] =>
[title] => 威望
[unit] =>
[ratio] => 0
[showinthread] =>
[allowexchangein] =>
[allowexchangeout] =>
[num] => 0
)
[2] => Array
(
[img] =>
[title] => 金钱
[unit] =>
[ratio] => 0
[showinthread] =>
[allowexchangein] =>
[allowexchangeout] =>
[num] => 25
)
[3] => Array
(
[img] =>
[title] => 贡献
[unit] =>
[ratio] => 0
[showinthread] =>
[allowexchangein] =>
[allowexchangeout] =>
[num] => 0
)
)
那模版里面的变量呢? 是$_G['setting']['extcredits'][1]吗?显示值是空
威望 - 0
金钱 - 25
贡献 - 0
威望 - 0
金钱 - 25
贡献 - 0
我是想单独调用每一项。因为给每一项都有一个标签。
威望 - 0
金钱 - 25
贡献 - 0
而且代码又溢出了,head标签的内容也被溢出到body标签里面了
调用出来了,可是代码溢出
目前已知的只有:$_G['member'][credits] 是当前用户的积分
回复讨论(解决方案)
\source\module\forum\forum_index.php
在这个页面中添加如下代码,在模板 discuz.htm 中直接调用就可以了
//威望,金钱 之类的可直接调用echo "";print_r($_G['setting']['extcredits']);echo "";//当前用户的 主题信息列表$threadList = C::t('forum_thread')->fetch_all_by_authorid_displayorder($_G['uid']);echo "";print_r($threadList);echo "";
\source\module\forum\forum_index.php
在这个页面中添加如下代码,在模板 discuz.htm 中直接调用就可以了
//威望,金钱 之类的可直接调用echo "";print_r($_G['setting']['extcredits']);echo "";//当前用户的 主题信息列表$threadList = C::t('forum_thread')->fetch_all_by_authorid_displayorder($_G['uid']);echo "";print_r($threadList);echo "";
不行啊
怎么不行
怎么不行
而且在输出的位置调用变量 输出值是空
//威望,金钱 之类的可直接调用foreach($_G['setting']['extcredits'] as $extcreditid=>$v){ //num 就是你要显示的值 $_G['setting']['extcredits'][$extcreditid]['num'] = getuserprofile('extcredits'.$extcreditid);}print_r($_G['setting']['extcredits']);
Array
(
[1] => Array
(
[img] =>
[title] => 威望
[unit] =>
[ratio] => 0
[showinthread] =>
[allowexchangein] =>
[allowexchangeout] =>
[num] => 0
)
[2] => Array
(
[img] =>
[title] => 金钱
[unit] =>
[ratio] => 0
[showinthread] =>
[allowexchangein] =>
[allowexchangeout] =>
[num] => 25
)
[3] => Array
(
[img] =>
[title] => 贡献
[unit] =>
[ratio] => 0
[showinthread] =>
[allowexchangein] =>
[allowexchangeout] =>
[num] => 0
)
)
//威望,金钱 之类的可直接调用foreach($_G['setting']['extcredits'] as $extcreditid=>$v){ //num 就是你要显示的值 $_G['setting']['extcredits'][$extcreditid]['num'] = getuserprofile('extcredits'.$extcreditid);}print_r($_G['setting']['extcredits']);
Array
(
[1] => Array
(
[img] =>
[title] => 威望
[unit] =>
[ratio] => 0
[showinthread] =>
[allowexchangein] =>
[allowexchangeout] =>
[num] => 0
)
[2] => Array
(
[img] =>
[title] => 金钱
[unit] =>
[ratio] => 0
[showinthread] =>
[allowexchangein] =>
[allowexchangeout] =>
[num] => 25
)
[3] => Array
(
[img] =>
[title] => 贡献
[unit] =>
[ratio] => 0
[showinthread] =>
[allowexchangein] =>
[allowexchangeout] =>
[num] => 0
)
)
那模版里面的变量呢? 是$_G['setting']['extcredits'][1]吗?显示值是空
数据都显示出来了,你循环啊
$extcredits['title'] - $extcredits['num']
威望 - 0
金钱 - 25
贡献 - 0
数据都显示出来了,你循环啊
$extcredits['title'] - $extcredits['num']
威望 - 0
金钱 - 25
贡献 - 0
我是想单独调用每一项。因为给每一项都有一个标签。
数据都显示出来了,你循环啊
$extcredits['title'] - $extcredits['num']
威望 - 0
金钱 - 25
贡献 - 0
而且代码又溢出了,head标签的内容也被溢出到body标签里面了
$_G['setting']['extcredits'][1]['num']
$_G['setting']['extcredits'][2]['num']
...
$_G['setting']['extcredits'][1]['num']
$_G['setting']['extcredits'][2]['num']
...
调用出来了,可是代码溢出
那你就把输出的地方去掉,print_r
你该多看看手册
你该多看看手册
下一篇: MongoDBJava连接