Dotclear

Changeset 922:74e3b2ee29f3


Ignore:
Timestamp:
10/27/12 15:11:14 (13 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Add tpl:TagCount and tpl:TagIf template tags, fixes #1105, thanks JcDenis?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/tags/_public.php

    r904 r922  
    2323$core->tpl->addBlock('TagsFooter',array('tplTags','TagsFooter')); 
    2424$core->tpl->addBlock('EntryTags',array('tplTags','EntryTags')); 
     25$core->tpl->addBlock('TagIf',array('tplTags','TagIf')); 
    2526$core->tpl->addValue('TagID',array('tplTags','TagID')); 
     27$core->tpl->addValue('TagCount',array('tplTags','TagCount')); 
    2628$core->tpl->addValue('TagPercent',array('tplTags','TagPercent')); 
    2729$core->tpl->addValue('TagRoundPercent',array('tplTags','TagRoundPercent')); 
     
    153155          return $res; 
    154156     } 
    155       
     157 
     158     public static function TagIf($attr,$content)  
     159     {  
     160          $if = array(); 
     161          $operateur = isset($attr['operator']) ? dcTemplate::getOperator($attr['operator']) : '&&'; 
     162 
     163          if (isset($attr['has_entries'])) { 
     164               $sign = (boolean) $attr['has_entries'] ? '' : '!'; 
     165               $if[] = $sign.'$_ctx->meta->count'; 
     166          } 
     167 
     168          if (!empty($if)) { 
     169               return '<?php if('.implode(' '.$operateur.' ',$if).') : ?>'.$content.'<?php endif; ?>'; 
     170          } else { 
     171               return $content; 
     172          } 
     173     } 
     174 
    156175     public static function TagID($attr) 
    157176     { 
     
    160179     } 
    161180      
     181     public static function TagCount($attr) 
     182     { 
     183          return '<?php echo $_ctx->meta->count; ?>'; 
     184     } 
     185 
    162186     public static function TagPercent($attr) 
    163187     { 
Note: See TracChangeset for help on using the changeset viewer.

Sites map