dedecms文章加入二维码

在内容页模板中加上以下代码即可

 

<img src="http://chart.apis.google.com/chart?chs=80x80&cht=qr&chld=L|0&chl=http://www.hack001.com/plus/view.php?aid={dede:php} $thisid = $refObj->Fields['id']; echo $thisid; {/dede:php} " alt="描述" widhtHeight="" widhtHeight=""/>

 

本站首发,相关问题可以到我的博客提问,转载注明:www.hack001.com

 

做完之后发现有人已经把他做成了标签,值得学习,原理一样一样,使用了谷歌的api接口,然后调用dede文章的文章id,进行二维码的生成

 

dede增加二维码功能

1、打开/include/extend.func.php文件,在文件结尾添加以下内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
if ( ! function_exists('qr_code'))
{
     
    function qr_code($aid,$widhtHeight ='150',$EC_level='L',$margin='0')
    {  
        $arr = GetOneArchive($aid);
        if($arr['arcurl']){
            $str = urlencode($arr['arcurl']);
        }else{
            $str = urlencode($GLOBALS['cfg_phpurl'].'/view.php?aid='.$aid);
        }
        return '<img src="http://chart.apis.google.com/chart?chs='.$widhtHeight.'x'.$widhtHeight.'&cht=qr&chld='.$EC_level.'|'.$margin.'&chl='.$str.'" alt="QR code" widhtHeight="'.$widhtHeight.'" widhtHeight="'.$widhtHeight.'"/>';
    }
}

2、在文章页模板​调用,{dede:field.id function="qr_code(@me,200);"/}

注:qr_code(@me,200)  200是二维码大小,可自行调整。

至此,dede增加二维码功能完成,适用dede5.6+

本文出自   http://www.3oom.com/blog/52.html

 

 

 

推荐大家用第二种方法,因为生成的二维码是静态的地址,并且生成也好一些