The calendar in [SPIP 1.8.2]

SPIP 1.8.2 makes it possible to view calendars in the public zone with the same kind of display as is visible in the private zone, and, more widely, to construct all manner of calendars using the page formatting tools available for such calendars. These possibilities are supplied with a new loop criteria and three new filters.

The agenda criteria accepts a variable number of argument parameters and therefore be written in two ways:
-  {agenda datetime, type, YYYY, MM, DD}
-  {agenda datetime, periode, YYYY, MM, DD, YYYY2, MM2, DD2}

The first two arguments are:

  1. an SQL field name of the type datetime (e.g. date or date_redac for the Articles table and date_time for the Breves (news items) table); this first argument is mandatory.
  2. a type of calendar (jour (day), semaine (week), mois (month) or periode (period)); by default, this value is mois (month)These two arguments must be literals (i.e. they can not be calculated dynamically from <code>#ENV variables or any other similar tags).

the next three arguments are optional and can be specified using tabs (with or without filters):

  1. YYYY a string of exactly 4 digits specifying a year;
  2. MM a string of exactly two digits specifying a month;
  3. DD a string of exactly 2 digits specifying a day.

If these values are omitted or null, they are replaced by those of the current date. These parameters represent the data of a day in the select period:
-  if the type is jour (day), it will display the items with a date matching that of the specified day,
-  if the type is semaine (week), it will display the items with a date in the same week as the date specified,
-  if the type is mois (month), it will display the items with a date in the same month as that specified (in this case, the day DD parameter is optional).

For example:

<BOUCLE_semaine(ARTICLES) {agenda date, semaine} {par date}>

displays a list of articles published in the current week.

<BOUCLE_art_principale(ARTICLES) {id_article}>
<BOUCLE_mememois(ARTICLES) {agenda date, mois, (#DATE|annee), (#DATE|mois)} {par date}>

displays a list of articles published in the same month as the current month.

In the event where the type argument (the second argument) equals periode, three other arguments can be specified after the other criteria, viz:
-  YYYY, MM, DD corresponds to the start date of the period,
-  YYYY2, MM2, JJ2 corresponds to the end date of the period.

If the second trio of arguments specifying the end date is omitted, the current date will be assumed as the end date, and if the first trio is also absent, the selection period will cover the entire duration period of the web site (for sites with lots of articles, the time to execute this loop will be excessive if no other criteria are applied to restrict the number of records returned).

For example:

<BOUCLE_art_principale(ARTICLES) {id_article}>
<BOUCLE_apres(ARTICLES) {agenda date, periode, (#DATE|annee), (#DATE|mois), (#DATE|jour)} {par date}>

lists that articles that have been published prior to the current article.

To format the items selected by a loop (particularly a loop with an agenda criteria) in the form of a calendar, SPIP offers three filters. These filters provide a display format similar to the calendar in the private zone with the same kind of navigation system.

-  The agenda_memo file is applied to a date tag (e.g. #DATE or #DATE_MODIF) and accepts four parameters:

  1. a description
  2. a title
  3. a URL representing the item with that title and that description (e.g. #URL_ARTICLE)
  4. a CSS class name

If the tag to which agenda_memo is applied is not null, it just remembers the date and the three first arguments in an array indexed by the last argument (the CSS class name) annd returns nothing (no display).

The use of the last argument as an index for the item to be remembered makes it possible to have several calendars on a single page. In addition, the class specified here will be assigned to that element in the calendar display supplied by agenda_affiche. As such, we can assign different styles to the elements. The calendrier.css stylesheet offers 28 different styles that proide an example of different calendar styles.

-  The agenda_affiche filter is applied to a tag returning the number of elements to be displayed (normally #TOTAL_BOUCLE) and accepts three parameters:

  1. a text which will be dispalys if the filtered tag returns nothing (0 elements to display);
  2. a type of calendar (jour (day), semaine (week), mois (month) or periode (period));
  3. the names of the CSS classes used in the call of the previous filter which make it possible to filter the elements to be displayed.

If the filtered tag returns null, this filter returns its first argument. Otherwise it returns the elements memorised by the agenda_memo filter formatted as the calendar type requested.

Only the elements indexed by agenda_memo with one of the CSS classes specified in the last argument will be displayed (or perhaps all of the elements if that parameter is omitted ). In this way, we can filter the elements to distribute them in several calendars on the same physical page.

The periode type will restrict the display to the period defined by the oldest element and the most recent element found, which makes it possible to provide a very long period without necessitating an overly long display.


<BOUCLE_memorise(ARTICLES) {agenda date, semaine}{par date}>[

displays the articles published in the current week as a calendar.

-  Finally, the agenda_connu filter tests if its argument is one of the four types of calendars recognised (jour, semaine, mois or periode).

This criteria and its filters are used by the new template models: agenda_jour.html, agenda_semaine.html, agenda_mois.html and agenda_periode.html, called from the agenda.html model template which specifies in its header the stylesheets and JavaScripts necessary (but replaceable if so desired). These templates therefore offer a representative example of typical usage.

Author Mark Published : Updated : 26/10/12

Translations : عربي, català, English, Español, français, italiano