<?php
class TagLibTagname__ extends TagLib{
    protected $tags = array(
         'Article' => array('attr' => 'limit,order','close' =>1)// attr 属性列表close 是否闭合（0 或者1 默认为1，表示闭合）
 	);
 public function _Tagname__ ($attr,$content){
       $attr = $this->parseXmlAttr($attr);
       $limit=$attr['limit'];//参数$limit，可通过模板传入参数值
       $order=$attr['order'];//$order$limit，可通过模板传入参数值
	   $order=empty($order)?'id desc':$order;
	   $cid=$attr['cid'];
	   $id=$attr['id'];
	   if($cid){
		  	$where="cid=$cid";
	   }
		if($id){
			$where="id=$id";
		}
       $str='<?php ';
       $str .= '$field=array("id","cid","title","create_time","content");';//定义需要调用的字段
       $str .= '$_list_news=M("Tagname__")->where("'.$where.'")->limit('.$limit.')->order("'.$order.'")->select();';//查询语句
       $str .= 'foreach ($_list_news as $_list_value):';
       $str .= 'extract($_list_value);';
       $str .= $content;
       $str .='<?php endforeach ?>';
       return $str;
       }
 }