SPIP - Contrib

[ar] [en] [es] [fr] [it]



Home page > Useful loops

Excluding items with a particular keyword.

Monday 22 January 2007, by Loiseau2nuit. Latest addition Monday 22 January 2007

All the versions of this article:


This loop enables your site to avoid displaying some items (section, article, news, ...) if they have been marked with a specific keyword.


This loop follows on from the one explained here: Displaying items with a specific keyword


<BOUCLE_exclude (ARTICLES) {titre_mot=excluded} {doublons}>
</BOUCLE_exclude>

<BOUCLE_display_non_excluded (ARTICLES) {tout} {doublons} >
<a href="#URL_ARTICLE">#TITRE</a>
</BOUCLE_display_non_excluded>

How does it work ?

- In this loop, all the job is handled by the criteria doublons. The first loop (BOUCLE_exclude) selects from among all the ARTICLES those which are tagged with keyword "excluded" (titre_mot=excluded

- The second loop (BOUCLE_display_non_excluded) displays all (tout) ARTICLES, except those which have already been selected by the previous loop, also coded with a (doublons) criteria.

- One can easily replace ARTICLES with RUBRIQUES, BREVES or SITES depending on which items are requested. When so doing, just adapt the content of "href" destination (#URL_RUBRIQUE, #URL_BREVE et #URL_SITE).

- The keyword used in this example is ’excluded’. You can easily replace it by another one you choose. Make sure not to have 2 or more keywords with the same name (’titre’) in 2 or more different keyword groups, unless of course you are intending to exclude them all.

P.S.

Originally posted by Olivier GENDRIN. Translated from French by Etienne B. ( loiseau2nuit [AT] no-log.org )


Reply to this article



Follow-up of the site's activity RSS 2.0 | Site Map | Private area | Charte et vie SPIP-Contrib | SPIP | L'autre.net