当使用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')/}
查看更多关于DEDECMS直接获取软件模型本地下载地址或服务器名称的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did187621