Coding with SPIP 3.0
SPIP3.0 Technical Documentation

> > > > afficher_nombre_objets_associes_a

afficher_nombre_objets_associes_a

The afficher_nombre_objets_associes_a pipeline is called to display information about the number of elements linked to a given editorial object. It can therefore be used to provide the number of elements linked to a given keyword when called from the keyword groups page as shown below:

  1. $texte_lie = pipeline(
  2. 'afficher_nombre_objets_associes_a',
  3. 'args'=>array(
  4. 'objet'=>'mot',
  5. 'id_objet'=>$id_mot),
  6. 'data'=>$texte_lie));

Download

The object’s type and identifier for which the associated links are to be counted are passed as arguments to the pipeline. The data key is an array of values that will be comma-separated and concatenated for display purposes.

Example

The "Agenda" plugin uses this pipeline to add the number of events that are linked to a keyword with the following function:

  1. function agenda_afficher_nombre_objets_associes_a($flux){
  2. if ($flux['args']['objet'] == 'mot'
  3. AND $id_mot = $flux['args']['id_objet']){
  4. $aff_articles = sql_in('A.statut', ($GLOBALS['connect_statut'] == "0minirezo") ? array('prepa','prop','publie') : array('prop','publie'));
  5. $nb = sql_countsel("spip_mots_evenements AS L LEFT JOIN spip_evenements AS E ON E.id_evenement=L.id_evenement LEFT JOIN spip_articles AS A ON E.id_article=A.id_article", "L.id_mot=".intval($id_mot)." AND $aff_articles");
  6. if ($nb)
  7. $flux['data'][] = singulier_ou_pluriel($nb, "agenda:info_un_evenement", "agenda:info_nombre_evenements");
  8. }
  9. return $flux;
  10. }

Download