J'ai essayé d'utiliser le code suivant pour obtenir un Termid d'un terme:Drupal - Comment obtenir terme Id de nom avec taxonomy_get_term_by_name
$term = taxonomy_get_term_by_name($address_string);
$termId = $term[0]->tid;
Il y a 1 résultat, mais il apparaît comme terme [30 ] - donc le code ci-dessus ne fonctionne pas.
Je pensais pouvoir accéder au terme tableau en regardant le premier élément - p. $ term [0]
Qu'est-ce que je fais mal?
Voici le résultat de var_dump ($ term):
array (size=1)
30 =>
object(stdClass)[270]
public 'tid' => string '30' (length=2)
public 'vid' => string '4' (length=1)
public 'name' => string 'Thonglor' (length=8)
public 'description' => string '' (length=0)
public 'format' => string 'filtered_html' (length=13)
public 'weight' => string '0' (length=1)
public 'vocabulary_machine_name' => string 'areas' (length=5)
Un grand merci,
PW
Cela fonctionne correctement. Votre terme a id = 30 dans la base de données. – user4035
'array_shift()' est votre ami ici – Clive