zoukankan      html  css  js  c++  java
  • dedecms 自定义标签的方法

    function lib_demotest(&$ctag,&$refObj)
    {
    global $dsql,$envs;
    //属性处理
    $attlist="row|12,titlelen|24";
    FillAttsDefault($ctag->CAttribute->Items,$attlist);
    extract($ctag->CAttribute->Items, EXTR_SKIP);
    $revalue = '';
    $innertext = $ctag->GetInnerText();
    $ctp = new DedeTagParse();
    $ctp->SetNameSpace('field', '[', ']');
    $sql = "SELECT * FROM dede_archives WHERE 1=1 limit 0, $row";
    $dsql->Execute('me',$sql);
    while($rs = $dsql->GetArray('me'))
    {
    //根据属性处理查询变量
    $rs['title'] = cn_substr($rs['title'], $titlelen);
    //获取底层模板
    $ctp->LoadSource($innertext);
    foreach($ctp->CTags as $tagid=>$ctag) {
    if(!empty($rs[strtolower($ctag->GetName())])) {
    $ctp->Assign($tagid,$rs[$ctag->GetName()]);
    }
    }
    //根据底层模板及查询变量得到处理结果
    $revalue .= $ctp->GetResult();
    }
    return $revalue;
    }
    

     在include/taglib/建一个demotest.lib.php  文件

    然在需要的模板文件里加入

    {dede:demotest row='10' titlelen='36'}
      [field:title/]
      {/dede:demotest}
    
  • 相关阅读:
    【SQL】DBCC(zz)
    Temporary Tables and Table Variables
    SQL特殊字符处理zz
    更改 Office 解决方案的安装路径
    SQL优化
    zzSQL Server性能优化
    SQL Server2005 表分区三步曲(zz)
    zz精妙SQL
    Deal with an annoying Message in Excel
    SQL技巧总结
  • 原文地址:https://www.cnblogs.com/vania/p/4522500.html
Copyright © 2011-2022 走看看