DedeCMS擷取文檔及欄目所在連結URL之擴充方法

來源:互聯網
上載者:User

/** * 擷取欄目完整URL路徑 by Windchaser QQ:939238564 * @param   $typeid  欄目ID|文檔ID * @link    http://down.chinaz.com/try/201202/1646_1.htm   從該文章代碼基礎上改編 * @return  String */function typeurl_arc($typeid,$type='tid'){    global $dsql,$cfg_basehost;    if($type == 'tid'){//擷取欄目完整URL地址        $typeurl = '';        $row = $dsql ->GetOne("SELECT typedir,namerule2,isdefault,typedir,defaultname FROM dede_arctype WHERE id=$typeid");        $row['namerule2'] = str_replace('{typedir}','',$row['namerule2']);        $row['namerule2'] = str_replace('{tid}',$typeid,$row['namerule2']);        $row['namerule2'] = str_replace('{page}',1,$row['namerule2']);        $row['typedir'] = str_replace('{cmspath}','',$row['typedir']);        switch ($row['isdefault']) {            case 0://連結到列表第一頁                $typeurl = $row['namerule2'];                break;            case 1://連結到預設頁                $typeurl = $row['typedir'].'/'.$row['defaultname'];                break;            default://使用動態網頁                $typeurl = '/plug/list.php?tid='.$typeid;                break;        }    }else if($type == 'aid'){//擷取文檔完整URL地址        $row = $dsql ->GetOne("SELECT cnn.namerule,arc.ismake,arc.senddate FROM dede_archives arc JOIN dede_arctype cnn ON arc.typeid=cnn.id WHERE arc.id=$typeid");        if($row['ismake'] == 1){            if(strpos($row['namerule'],'/') == 0){                $row['namerule'] = substr($row['namerule'],1);            }            $row['namerule'] = str_replace('{aid}',$typeid,$row['namerule']);            $row['namerule'] = str_replace('{Y}',date('Y',$row['senddate']),$row['namerule']);            $row['namerule'] = str_replace('{M}',date('m',$row['senddate']),$row['namerule']);            $row['namerule'] = str_replace('{D}',date('d',$row['senddate']),$row['namerule']);            $typeurl = '/'.$row['namerule'];        }else{            $typeurl = '/plug/view.php?aid='.$typeid;        }          }    $typeurl = $cfg_basehost.$typeurl;    return $typeurl;}

DEDECMS模版標籤的一個擴充方法!

目的是擷取欄目或者文檔的完整URL地址!

文檔和列表的標籤調用小有不同!

列表:

{dede:field.typeid function='typeurl_arc(@me)'/}

文檔:

{dede:field.id function='typeurl_arc(@me,aid)'/}


本文出自 “逆襲逐風” 部落格,請務必保留此出處http://windchaser.blog.51cto.com/5742634/1301449

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.