曹义 發表於 2023-12-13 00:00:00

为dedecms增加二维码功能的实现代码

<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        dede增加二维码功能</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        <strong>1、打开/include/extend.func.php文件,在文件结尾添加以下内容</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode1" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        if ( ! function_exists('qr_code'))<br>
        {<br><br>
        function qr_code($aid,$widhtHeight ='150',$EC_level='L',$margin='0')<br>
        { <br>
        $arr = GetOneArchive($aid);<br>
        if($arr['arcurl']){<br>
        $str = urlencode($arr['arcurl']);<br>
        }else{<br>
        $str = urlencode($GLOBALS['cfg_phpurl'].'/view.php?aid='.$aid);<br>
        }<br>
        return '&lt;img src="http://chart.apis.google.com/chart?chs='.$widhtHeight.'x'.$widhtHeight.'&amp;cht=qr&amp;chld='.$EC_level.'|'.$margin.'&amp;chl='.$str.'" alt="QR code" widhtHeight="'.$widhtHeight.'" widhtHeight="'.$widhtHeight.'"/&gt;';<br>
        }<br>
        }</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        <strong>2、在文章页模板​调用,{dede:field.id function="qr_code(@me,200);"/}</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        注:qr_code(@me,200)  200是二维码大小,可自行调整。<br><br>
        至此,dede增加二维码功能完成,适用dede5.6及以上版本 <br><br><strong>google提供二维码生成器</strong> <br><br>
        其实就是参考下面的传参方法 <br>
        http://chart.apis.google.com/chart?cht=qr&amp;chs=200x200&amp;chl=https://www.jb51.net&amp;amp;choe=UTF-8<br><br>
        在后台系统-核心设置里“(是/否)支持多站点,开启此项后附件、栏目连接、arclist内容启用绝对网址:”这个下面设置为是 就可以开启绝对路径,生成出来的网址就没问题。</p>
頁: [1]
查看完整版本: 为dedecms增加二维码功能的实现代码