Dedecms list page output attachment download address

Source: Internet
Author: User

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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.