ez.no / exponential / documentation / customization / custom design / examples / common template issues / complex list with colours
In the final example we set alternating colours for the lines in the list, using the 'sequence' function. Sequence is used two loop trough a list, and wrap around when the end is reached. This is very useful for alternating colours. We set two parameters, the namespace and the array of items to loop. (In this case the array contains four items, allthough we only use two colours. This is because the section loops over table cells, and there are two cells per line.) We get the current sequence item using the namespace and 'item', and we advance to the next item by calling sequence again with the same namespace.
{* set children variable *} {let children=fetch('content',list,hash(parent_node_id,$node.node_id))} <h1>{$node.name}</h1> <table border='0'> {section name=Child loop=$children max=2} <tr> <td colspan="2"> <h2>{$Child:item.name}</h2> <p>{$Child:item.data_map.intro.data_text}</p> <p><a href={concat("/content/view/full/",$Child:item.node_id)|ezurl}>Read more...</a></p> </td> </tr> {/section} <tr> <td colspan="2"> <h2>More news:</h2> </td> </tr> <tr> {sequence name=Seq loop=array("#A0FFA0","#A0FFA0","#D0FFD0","#D0FFD0")} {section name=Child loop=$children offset=2} <td bgcolor="{$Seq:item}"> {node_view_gui view=line content_node=$Child:item} </td> {* Get next item in the sequence *} {sequence name=Seq} {delimiter modulo=2} </tr> <tr> {/delimiter} {/section} </tr> </table> {/let}
This will output something like this:
TODO: add screenshot
Log in or create a user account to comment.
Comments