ez.no / exponential / documentation / customization / custom design / examples / common template issues / complex list
Since this is a news page example, we will now try some functionality that might be used on a news site. We show the two most recent news titles on the top, with the ingress, and a link to the full article. For the remaing articles we simply show the name, linked to the full article, as in the previous example. To achieve this we use the 'max' and 'offset' input parameters. In the first loop we set 'max=2', meaning that up to two items will be show in this loop. In the second loop we set 'offset=2', meaning that this loop will start two items from the beginning of the list, in other words with the third item.
We also use the 'delimiter' function to show the remaing articles in a two-column list. The delimiter function is used when we want to do something between each item in a loop. In this case we output the closing and starting -tags. We set 'modulo=2' for the delimiter, meaning that the delimiter will only be used for every second list item. Thus, this part of the table will contain two cells per row.
{* 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> {section name=Child loop=$children offset=2} <td> {node_view_gui view=line content_node=$Child:item} </td> {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