Note:
InDedecmsDirectly output the download link for the attachments contained in the document in the list.
Usage:
[field:body function="getDownloadUrl(@me)" /] |
Operation:
Two files need to be modified:
First:/include/extend. func. php
Second:/include/FCKeditor/Editor/dialog/dede_addon.php
Add a function to the first file:
/** * Description: The attachment address in the output article content. The parameter is the article content. **/ function getDownloadUrl( $string , $name = 'Download attachment' , $target = "_blank" ){ if ( empty ( $string )) return '' ; $rs = preg_match( '/regfile="(.*?)"/i' , $string , $array ); if (! empty ( $array [1])){ $url = $array [1]; // The function used in the template tag cannot input multiple parameters, so one piece of HTML output $html = '<a href="' . $url . '" target="' . $target . '">(' . $name . ')</a>' ; return $html ; } // 'Function ...... '; } |
Modify the rvalue of the OK function in the second file:
function Ok() { var rurl,widthdd,heightdd,rvalue,rurlname,addonname; rurlname = form1.rurl.value; addonname = form1.rname.value; if (addonname== '' ) addonname = rurlname; rurl = encodeURI(form1.rurl.value); rvalue = '<table width="450">' ; rvalue += '<tr><td height="30" width="20">' ; rvalue += '<a href="' + rurl+ '" target="_blank">/img/addon.gif" border="0" align="center"></a>' ; rvalue += '</td><td>' ; // Add the regfile attribute for sign-In A for the newly added getfileurl function. rvalue += '<a regfile="' + rurl + '" href="' + rurl + '" target="_blank"><u>' + addonname + '</u></a>' ; rvalue += '</td></tr></table>' ; oEditor.FCK.InsertHtml(rvalue); return true ; } |
<End>