织梦园模板网提供云优cms模板,pbootcms模板,Wordpress主题模板等各类企业新闻资讯网站模板下载服务。织梦园网站模板交流群
用户名:
密码:
注册
注册后享受折扣价

织梦首页/列表页直接获取软件模型本地下载地址

织梦园模板 / 2019-03-24 / 收藏

当使用软件模型而且只有一个下载地址时,我们都喜欢用本地地址,在列表页时直接输出这个地址,方便访客下载。

打开 \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 `dede_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)/}

相关织梦教程

收缩