New answers tagged taxonomy-terms
1
vote
Unable to add newly created term to the node
To append an entity reference item use:
$node->field_foo[] = ['target_id' => 123];
And as Kevin noted in the comments, make sure you save the entity.
$node->save();
0
votes
Related content by taxonomy term but using a relationship between terms
I solved this using Views Token Arguments - solution here:
https://www.drupal.org/forum/support/post-installation/2022-05-07/related-content-by-taxonomy-term-but-using-a-relationship-between-terms
0
votes
Token service not replacing text with term as a token
Drupal out-of-the-box has only basic token support, which can replace core entity standard fields like [term:name] or [term:description].
Configured fields, usually those with a prefix field_, need ...
0
votes
How to display a comma-separated list of multiple field values?
The https://drupal.stackexchange.com/a/238069/5501 should work.
However if you need to remove all markup from the output and ensure no whitespaces/new lines exists in it then it become tricky:
items|...
0
votes
How can I get the machine name of a taxonomy term knowing its tid?
With D8 something like this.
$parameters = \Drupal::routeMatch()->getParameters()->all();
if (isset($parameters['taxonomy_term'])) {
$term = $parameters['taxonomy_term'];
$vid = $term->...
0
votes
Retrieve translated taxonomy term in current language programatically
An approach in preprocess node (handles multiple term references):
function HOOK_preprocess_node(&$variables) {
$node = $variables['node'];
$langcode = \Drupal::languageManager()->...
Top 50 recent answers are included
Related Tags
taxonomy-terms × 3594views × 1290
7 × 1120
8 × 430
nodes × 408
entities × 350
theming × 224
users × 156
6 × 114
i18n-l10n × 94
path-aliases × 90
search × 89
forms × 88
routes × 84
commerce × 71
rules × 67
blocks × 60
database × 57
ajax × 57
uri × 53
migrations × 52
panels × 48
hooks × 43
media × 37
navigation × 37