(edit)
Hide minor edits - Show changes to markup
(:redirect 'http://docs.studip.de/develop/Entwickler/TextHelper':)
(:source lang=htm linenum:)[@
(:source lang=php linenum:)[@
(:source lang=xhtml linenum:)[@
(:source lang=html linenum:)[@
(:source lang=php linenum:)[@ <? // Beispiel für 2 Tabellenzeilen ?>
</tr>
<? endforeach ?>
<? // Komplexeres Beispiel für verschachtelte Wechsel ?> <? foreach($items as $item) : ?>
<tr class="<?= TextHelper::cycle(array("even", "odd", "name" => "row_class")) ?>"> <td> <? foreach ($item->values as $value) : ?> <span style="color:<?= TextHelper::cycle(array("red", "green", "blue", "name" => "colors")) : ?>"> <?= $value ?> </span> <? endforeach ?> <? TextHelper::reset_cycle("colors") ?> </td>
Returns a camelized string from a lower case and underscored string by replacing slash with underscore and upper-casing each letter preceded by an underscore.
Creates a Cycle object whose +__toString method cycles through elements of an array every time it is called.
You can use named cycles to allow nesting in loops. Passing a single array as the only parameter with a <tt>name</tt> key will create a named cycle. You can manually reset a cycle by calling reset_cycle and passing the name of the cycle.
<? foreach ($items as $item) : ?> <tr class="<?= TextHelper::cycle('odd', 'even') ?>"> <td><?= item ?></td> </tr> <? endforeach ?>
Diese Klasse der FlexiTemplates bieten einige nützliche Funktionen, die oft benötigte aufgaben in Templates erledigen.
Source: Basis-Wiki-Hilfe | Last change: April 01, 2011, at 11:42 PM, tthelen | Local view: Basis-Hilfe