Dotclear


Ignore:
Timestamp:
03/20/13 11:38:16 (12 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Add LoopIndex? template tag (return current loop index, 1 to n, and return 0 if no current loop).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/public/class.dc.template.php

    r980 r1122  
    4242          # Loops test tags 
    4343          $this->addBlock('LoopPosition',array($this,'LoopPosition')); 
     44          $this->addValue('LoopIndex',array($this,'LoopIndex')); 
    4445           
    4546          # Archives 
     
    528529          "<?php endif; ?>"; 
    529530     } 
     531 
     532     public function LoopIndex($attr) 
     533     { 
     534          $f = $this->getFilters($attr); 
     535          return '<?php '.sprintf($f,'(!$_ctx->cur_loop ? 0 : $_ctx->cur_loop->index() + 1)').' ?>'; 
     536     } 
    530537      
    531538      
Note: See TracChangeset for help on using the changeset viewer.

Sites map