udm_cat_path

(PHP 4 >= 4.0.6, PHP 5 <= 5.0.5, PECL mnogosearch:1.0.0)

udm_cat_path — Lit le chemin de la catégorie courante

Description

array udm_cat_path ( resource $agent, string $category )

udm_cat_path() retourne un tableau listant les catégories depuis la racine jusqu'à la catégorie courante. Le paramètre agent est un identifiant de résultat, obtenu après un appel à udm_alloc_agent .

category - La catégorie courante : celle dont on veut le chemin.

udm_cat_path() retourne un tableau avec le format suivant :

Le tableau est constitué de paires. Les index pairs contiennent les chemins de catégories, les index impairs les noms des catégories correspondantes.

Par exemple, l'appel $array=udm_cat_path($agent, '02031D'); peut retourner le tableau suivant :


 $array[0] contiendra ''
 $array[1] contiendra 'Root'
 $array[2] contiendra '02'
 $array[3] contiendra 'Sport'
 $array[4] contiendra '0203'
 $array[5] contiendra 'Foot'
 $array[4] contiendra '02031D'
 $array[5] contiendra 'PSG'

   

Exemple 1521.  Spécifier une catégorie avec un format hiérachisé

<?php
//Spécifier le chemin de la catégorie courante avec le format suivant 
// '> Root > Sport > Foot > PSG'
  
$cat_path_arr  udm_cat_path ( $udm_agent $cat );
  
$cat_path  '' ;
  for (
$i = 0 $i < count ( $cat_path_arr );  $i += 2 ) {
    
$path  $cat_path_arr [ $i ];
    
$name  $cat_path_arr [ $i + 1 ];
    
$cat_path  .=  " > <a href=\"$_SERVER[PHP_SELF]?cat=$path\">$name</a> " ;
  }
?>

Voir aussi udm_cat_list() .