花魁直播高品质美女在线视频互动社区 - 花魁直播官方版

 歡迎來到素材無憂網(wǎng),按 + 收藏我們
登錄 注冊(cè) 退出 找回密碼

dede 自定義表單導(dǎo)出功能的實(shí)現(xiàn)詳細(xì)步驟

時(shí)間: 2018-12-01 10:11 閱讀: 作者:素材無憂網(wǎng)

DEDE自定義表單導(dǎo)出功能的實(shí)現(xiàn)詳細(xì)步驟,這個(gè)代碼是通用的!加完后  你所有的自定義表單 都可以導(dǎo)出!


步驟:
1.打開 /dede/templets/diy_main.htm   大概在第49行的地方加上
<a href="../plus/diy.php?action=push&diyid={dede:field.diyid/}" target="_blank">導(dǎo)出</a>
意思就是加個(gè)導(dǎo)出按鈕。

2.打開 /plus/diy.php   在最下面加入以下代碼
else if($action == 'push')
{
  $row = $dsql->GetOne("Select * From dede_diyforms where diyid='$diyid'");
  $ds = file(('/dede/inc/fieldtype.txt'));
foreach($ds as $d){
$dds = explode(',',trim($d));
$fieldtypes[$dds[0]] = $dds[1];
}
$fieldset = $row['info'];
$dtp = new DedeTagParse();
$dtp->SetNameSpace("field","<",">");
$dtp->LoadSource($fieldset);
$titleArray=array();
$titleName=array();
if(is_array($dtp->CTags)){
foreach($dtp->CTags as $ctag)
{
$itname = $ctag->GetAtt('itemname');
if($itname=='') echo "沒指定";
$titleArray[] = $itname;
$titleName[]= $ctag->GetTagName();
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename=demo.xls');
header('Pragma: no-cache');
header('Expires: 0');
$title =$titleArray;
include_once DEDEINC.'/datalistcp.class.php';
    if($diy->public == 2)
        $query = "SELECT * FROM `{$diy->table}` ORDER BY id DESC";
    else
        $query = "SELECT * FROM `{$diy->table}` WHERE ifcheck=1 ORDER BY id DESC";

    $datalist = new DataListCP();
    $datalist->pageSize = 10;
    $datalist->SetParameter('action', 'list');
    $datalist->SetParameter('diyid', $diyid);
    $datalist->SetSource($query);   
$rsArray = array();
$datalist->dsql->Execute('dlist',$datalist->sourceSql);
        $i = 0;
        while($arr=$datalist->dsql->GetArray('dlist'))
        {
        $i++;  
        $object = array();
        foreach ($titleName as $va){
        $object[]=$arr[$va];
        }
            $rsArray[$i] = $object;
           
        }
$data = $rsArray;
echo iconv('utf-8', 'gbk', implode("\t", $title)), "\n";
foreach ($data as $value) {
echo iconv('utf-8', 'gbk', implode("\t", $value)), "\n";
}
exit;
}



就OK了。


思路很簡(jiǎn)單,先在列表頁(yè)搞個(gè)可以觸發(fā)導(dǎo)出的按鈕,然后把需要導(dǎo)出的表頭和內(nèi)容查出來,然后以execle輸出就好了。

版權(quán)聲明: 本站資源均來自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!

轉(zhuǎn)載請(qǐng)注明: dede 自定義表單導(dǎo)出功能的實(shí)現(xiàn)詳細(xì)步驟

標(biāo)簽:  
模板推薦