zoukankan      html  css  js  c++  java
  • OneThink友情链接插件使用!

    OneThink友情链接插件使用:

    直接安装插件就好,查看数据库会有:onethink_links 这个表:

    写 links 标签,调用友情链接:

    <?php
    namespace CommonTag;
    use ThinkTemplateTagLib;
    class My extends TagLib{
        // 定义标签
        protected $tags = array(
            'links'=> array('attr'=>'type,row')
        );
        public function _links($attr,$content){
            //调用父类
            $type = isset($attr['type']) ? $attr['type'] : '1';
            $limit = isset($attr['row']) ? $attr['row'] : '5';
            // 组合PHP代码的字符串
            $str = '<?php ';
            $str .= '$where = array("type" =>'.$type.',"status"=>1,"order"=>0);';
            $str .= '$_links = M("links")->where($where)->order("sort desc")->limit('.$limit.')->select();';
            $str .= 'foreach($_links as $v):';
            $str .= 'extract($v);?>';
            $str .= $content;
            $str .= '<?php endforeach;?>';
            return $str;
        }
    };

    前台模板输出:

    <links type='2' row='2'>
        <a href="{$link}">{$title}</a>
    </links>

    友情链接插件同样也支持上传图片,此功能后续!

  • 相关阅读:
    CentOS 6.5通过yum的方式安装MySql
    Hbase集群搭建
    Thread类的常见问题
    关hashMap跟hashTable的区别
    mysql 循环插入100w
    Centos 多个mysql数据库
    CentOS 搭建 FastDFS-5.0.5集群
    RPC
    dubbo简述
    自己去看dubbo源码
  • 原文地址:https://www.cnblogs.com/e0yu/p/7367740.html
Copyright © 2011-2022 走看看