PUBLIE : #INFO_XXX

**SPIP**

# Article validé

L’article "**#INFO_XXX** (https://www.spip.net/en_article6547.html)"
vient d’être publié par b_b.

* * *

## #INFO_XXX

mercredi 13 mai 2020 , par [jack](.././?page=auteur&id_auteur=593&)

**`#INFO_XXX{objet_type, id_objet}`** is a tag that allows you to retrieve
the value of a field in the database without necessarily making a boucle
(https://www.spip.net/ecrire/?exec=article&id_article=898).

It takes three mandatory parameters :

1. **XXX** : the name of the field
2. **objet_type** : this is the type of the object [1] function
corresponding to the SQL table you want to query (e.g. : *article* for the
spip_articles table, *forum* for the spip_forum table, etc.).
3. **id_objet** : this is the id of the targeted object.

## Off-loop use

    #INFO_TITRE

    {article, 13}

    #INFO_NOM

    {auteur, 2}

This feature is optimized to avoid making multiple SQL queries on the same
table. So you can use the tag several times on the same object without
worrying.

    #INFO_TITRE

    {article, 13}

    #INFO_SOUSTITRE

    {article, 13}

    #INFO_CHAPO

    {article, 13}

Parameters can also be passed dynamically :

    #SET

    {id_breve, 3}

    #INFO_TITRE

    {breve,
    
    #GET
    
    {id_breve}}

## Use in a loop

    <BOUCLE_article

    (ARTICLES)

    {id_article}

    >

    Here's the article
    
    #TITRE
    
     de la rubrique
    
    #INFO_TITRE

    {rubrique,
    
    #ID_RUBRIQUE
    
    }

    </BOUCLE_article>

...works well since `#ID_RUBRIQUE` is a field from the table
`spip_articles`

## Automatic treatments

The tag applies the usual automatic processing to the requested
information, exactly as when #TITRE or #TEXTE is requested in a loop of the
object. It therefore takes into account multi tags or SPIP syntax on
certain fields.

To not apply them, it is necessary to add the asterisk [2] , as for the
other tags : `#INFO_TEXTE*{article, 123}`.

## Specificities

For TITRE, the tag will look for the definition of the title field in the
description of the editorial object [3] , which then allows to use the same
syntax whatever the content, even if in the database it is the "name" field
that is important.

Thus `#INFO_TITRE{auteur, 123}` will return the nickname of this user,
stored in the "name" field of "spip_auteurs".

## See also

Les balises propres au site
(https://www.spip.net/ecrire/?exec=article&id_article=1902)

[1] see on this subject the objet_type()
(https://code.spip.net/autodoc/tree/ecrire/base/objets.php.html#function_objet_type)

[2] see #BALISE* et #BALISE**
(https://www.spip.net/ecrire/?exec=article&id_article=4376), as well as the
Automatic tag processes
(https://programmer.spip.net/Traitements-automatiques-des)

[3] see on this subject the API de déclaration d’objets éditoriaux
(https://www.spip.net/ecrire/?exec=article&id_article=5525)

— Envoyé par SPIP (https://www.spip.net/)

rubon199.jpg