如何在discuz的discuz.htm中調用當前登陸使用者的主題、各項積分等資訊

來源:互聯網
上載者:User
如何在discuz的discuz.htm中調用當前登陸使用者的主題、各項積分等資訊
目前已知的只有:$_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
你該多看看手冊

你該多看看手冊

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.