Basic Syntax
The basic syntax for a loop is as follows:
* Code HTML + balises SPIP
We saw, in the overview of loops and tags, that the HTML code + SPIP’s tags of the above example are repeated as many times as the loop can extract items from the database (in other words, once, several times, or not at all).
The main instruction here is:
- The word BOUCLE is an instruction given to Spip to define a new loop and cannot be modified: all Spip loops must start with the command BOUCLE.
- The n element is the loop’s identifier. It can be either a name or a number and is chosen by the webmaster for every loop he or she makes. We will see later how it is possible to use several loops in the same template. This is after all the object of the exercise, and because of this it is essential for each loop to have a unique identifier.
If you decide to number your loops, the syntax for loop 5 would be:
...
If you decide to give a name to your loops, which is usually more convenient and makes your code easier to read, then the name must start with the underscore symbol “_”. For example:
...
- (TYPE) is a key element defining what kind of items are to be displayed. The syntax is important: the TYPE must be entered between parenthesis, with no spaces, in capital letters, and must be one of the types specified by Spip: ARTICLES, RUBRIQUES, AUTEURS, BREVES, etc. (they are all covered in this documentation).
So, continuing with the previous example, we now have:
...
No comments:
Post a Comment