1. 程式人生 > >織夢首頁/列表頁/內容頁直接獲取軟體模型本地下載地址

織夢首頁/列表頁/內容頁直接獲取軟體模型本地下載地址

當使用軟體模型而且只有一個下載地址時,我們都喜歡用本地地址,在列表頁時直接輸出這個地址,方便訪客下載。

開啟 /include/extend.func.php 在檔案最下面添加個方法

/**
 *  獲取軟體模型本地地址
 *
 * @access    public
 * @param     string  $aid  	文章id
 * @return    string
 */
if (!function_exists('GetDownLink'))
{
    function GetDownLink($aid)
    {
       global $dsql;
       $row= $dsql->GetOne("SELECT softlinks FROM `#@_addonsoft` WHERE aid = {$aid}");
           if(!is_array($row)){
            return '';
            }
           else{
            $dtp = new DedeTagParse();
            $dtp->LoadSource($row['softlinks']);
                foreach($dtp->CTags as $ctag)
                {
                    if($ctag->GetName()=='link')
                {
                    $link = trim($ctag->GetInnerText());
                }
            }
       }
       return  $link;
    }
}

前臺模板中呼叫標籤寫法

首頁/列表頁

[field:id function=GetDownLink(@me)/]

內容頁

{dede:field.id function=GetDownLink(@me)/}