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

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:09:21 am
by B�rd Farstad

Last updated

04/07/2003
11:09:21 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.