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

Comments

Log in or create a user account to comment.

Contents

Customization

Access control
Exponential API Documentation
Content structure
Custom design
    User specified parameters
    Template variables set by Exponential
    Introduction
    Variables, arrays and objects
    Node
    Database connectivity
    Sections
    File placement
    Override templates
    node_view_gui
    Pagination
    Caching
    Stylesheets
    Pagelayout
    Printable pages
    Examples
       Template language
       Creating a navigation path
       Common template issues
          Complex list
          Complex list with colours
          List with links
Components
Tips & Tricks
Troubleshooting


Created

04/07/2003
11:10:11 am
by B�rd Farstad

Last updated

04/07/2003
11:10:11 am
by B�rd Farstad

Authors

B�rd Farstad



This page is part of the Exponential documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.