时间:2021-01-09日 来源: 作者: 
当使用DEDECMS软件模型而且只有一个下载地址时,我们都喜欢用本地地址,在列表页时直接输出这个地址,方便访客下载。
打开 /include/extend.func.php 在文件最下面添加个方法
- /**
 - * 获取软件模型本地地址
 - *
 - * @access public
 - * @param string $aid 文章id
 - * @return string $type 本地地址/服务器名称
 - */
 - if (!function_exists('GetDownLink'))
 - {
 - function GetDownLink($aid,$type='link')
 - {
 - global $dsql;
 - $row= $dsql->GetOne("SELECT softlinks FROM `aspkus_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());
 - $name = trim($ctag->GetAtt('text'));
 - }
 - }
 - }
 - return ${$type};
 - }
 - }
 
前台模板中调用标签写法
首页/列表页
本地地址:[field:id function=GetDownLink(@me)/]
服务器名称:[field:id function=GetDownLink(@me,'name')/]
内容页
本地地址:{dede:field.id function=GetDownLink(@me)/}
服务器名称:{dede:field.id function=GetDownLink(@me,'name')/}
相关文章
推荐文章
热门文章
