新聞中心
DEDECMS 如何調(diào)用會員信息在個人模板info和index
在dedecms中,會員index.php以及變量文件index_do.php都由變量控制,首頁模板在index.php中改寫,其他文件則在會員文件夾下Inc/space_action.php中有說明。 會員信息在個人模板info和index的調(diào)用問題,好長時間沒解決,論壇發(fā)帖沒人回答,通過一晚上的觀察,看了一晚上代碼 無憂主機小編解決了。 會員個人空間 index.htm 、 listarticle.htm不能像infos.htm模板一樣使用 <?php echo GetEnumsValue('pfirst',$row['pfirst']); ?> 語句來調(diào)用自定義聯(lián)動數(shù)據(jù),會報錯 以下為例子,要讓index.htm同樣和infos.htm一樣調(diào)用處聯(lián)動數(shù)據(jù),header.htm跟隨模板文件的改動而相應,比如infos支持,這個頁面的header.htm加在調(diào)用會成功,否則失敗報錯。 將Inc/space_action.php文件中的 /*--------------------------------- 個人資料 function infos(){ } -------------------------------------*/ else if($action=='infos') { include_once(DEDEDATA.'/enums/nativeplace.php'); include_once(DEDEINC."/enums.func.php"); $row = $dsql->GetOne("select * from `dede_member_person` where mid='{$_vars['mid']}' "); $dpl = new DedeTemplate(); $dpl->LoadTemplate(DEDEMEMBER."/space/{$_vars['spacestyle']}/infos.htm"); $dpl->display(); } 拷貝到index.php 經(jīng)過篩選后的此位置, /*----------------------------- //會員空間主頁 function space_index(){ } ------------------------------*/ else { require_once(DEDEMEMBER.'/inc/config_space.php'); if($action == '') { include_once(DEDEINC."/channelunit.func.php"); $dpl = new DedeTemplate(); $tplfile = DEDEMEMBER."/space/{$_vars['spacestyle']}/index.htm"; 改寫方式如下 /*----------------------------- //會員空間主頁 function space_index(){ } ------------------------------*/ else { require_once(DEDEMEMBER.'/inc/config_space.php'); include_once(DEDEDATA.'/enums/nativeplace.php');/*--后添加復制過來--*/ include_once(DEDEINC."/enums.func.php");/*--后添加復制過來--*/ if($action == '') { include_once(DEDEINC."/channelunit.func.php"); $row = $dsql->GetOne("select * from `dede_member_person` where mid='{$_vars['mid']}' ");/*--后添加復制過來--*/ $dpl = new DedeTemplate(); $tplfile = DEDEMEMBER."/space/{$_vars['spacestyle']}/index.htm"; 綜上所述 只要在相應的位置添加以下三條數(shù)據(jù)即可 include_once(DEDEDATA.'/enums/nativeplace.php');/*--后添加復制過來--*/ include_once(DEDEINC."/enums.func.php");/*--后添加復制過來--*/ $row = $dsql->GetOne("select * from `dede_member_person` where mid='{$_vars['mid']}' ");/*--后添加復制過來--*/ 備注:相應的其他頁面只需要在 Inc/space_action.php 統(tǒng)一添加三條語句就可以實現(xiàn)了。
本文地址:http://m.gle-technology.com/dedecms/15658.html