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:

$texte_lie = pipeline(
	'afficher_nombre_objets_associes_a',
	array(
		'args'=>array(
			'objet'=>'mot',
			'id_objet'=>$id_mot),
		'data'=>$texte_lie));

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:

function agenda_afficher_nombre_objets_associes_a($flux){
	if ($flux['args']['objet'] == 'mot'
	  AND $id_mot = $flux['args']['id_objet']){
		$aff_articles = sql_in('A.statut',  ($GLOBALS['connect_statut'] == "0minirezo")  ? array('prepa','prop','publie') : array('prop','publie'));
		$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");
		if ($nb)
			$flux['data'][] = singulier_ou_pluriel($nb, "agenda:info_un_evenement", "agenda:info_nombre_evenements");
	}
	return $flux;
}

Author Mark Baber Published : Updated : 12/03/23

Translations : English, français