|
You are here: Home / Documentation / How To: XT Template Essentials |
How To: XT Template EssentialsLoopsIt is easy to think of examples of situations where you need to loop through data to present it: Any list of things will do. Therefore, the ability to loop through data while rendering it into a template is a valuable one. XT, like most template languages, has such a facility, and a rather powerful one at that. Let's look at a very basic example to start with:<xt:tpl> The loop shown above will render five table cells in a row with the numbers 1 through 5 in them. As you can see, you refer to the loop values through the "loop/item" object, which corresponds to the name of the variable in the loop expression. Consider the following PHP code for an understanding of the use of "loop/item": <?php "loop/item" corresponds to "$item" in the above code. However, the addition of the "/number" should appear peculiar as well. The reason for this is that a loop object in XT contains more than simply the value of the current loop item. These additional attributes are referred to by name, as is any other property of an object, and they are:
Now let's look at a more complex example: <xt:tpl>Here you can see where the power of XT's looping constructs can come into play, allowing for the ability to easily loop through and utilize complex data structures. Next Up: Includes Page 1: Introduction |
|
Copyright © 2008, SIMIAN systems Inc. All rights reserved. Privacy policy Some of the icons on this site were created by the Gnome Project. |