SPIP

[ar] [bg] [ca] [cpf] [cs] [da] [de] [en] [eo] [es] [eu] [fa] [fon] [fr] [gl] [id] [it] [ja] [lb] [nl] [oc] [pl] [pt] [ro] [sv] [tr] [vi] [zh] Espace de traduction

Download the latest version of SPIP

SPIP 1.9.2 SPIP 1.9.2

A section

How to make a contents page

October 2003

All the versions of this article:


In the preceding lesson we learned how to display elements according to the context. We here see how this context varies depending on the loop, BOUCLES, being processed.

Let us modify our "tutorial.html" template in the following way:

Here, we’ve removed the {id_article} condition altogether. A word of caution, this loop can generate a large page if your database contains a lot of articles; it is worth taking precautions by adding {0,10} to limit the loop to the first 10 articles.

<BOUCLE_article(ARTICLES){0,10}>

And the result, simply calling http://yoursite.net/tutorial.php3 (no need for id_article from now on, since this condition was removed from the template), the titles of the first 10 published articles are displayed, each on a separate line. From this, you can see how you can produce the synopsis of a section. Now let us display the 10 most recent articles in this section:

Let us take this in order:
-  id_rubrique: only includes the articles belonging to the id_rubrique section (see below that this variable is defined in the context of our BOUCLE_article);
-  {par date}{inverse}: sort by date starting with the newest.
-  {0,10}: ... and take only the first 10 results.
-  Lastly, the code <a href="#URL_ARTICLE">#TITRE</a> will display not only the title of the article but also links to those articles.

All that remains is to call the template, while passing the context id_rubrique=1:

http://yoursite.net/tutorial.php3?id_rubrique=1

The SPIP magic is in the combination of this type of functionality. If you reached this point, you’re doing great!


ٍShow the template of this page Site created with SPIP | Translation area | Private area