Get taxonomy terms of a vocabulary - Drupal 8 | Drupal 8

Get taxonomy terms of a vocabulary - Drupal 8

Submitted by editor on Tue, 11/17/2015 - 19:13
Question

How to get the taxonomy terms  list of a selectes vocabulary ?

Using entityQuery, you can get the taxonomy terms  of a particular vocabulary.

    $query = \Drupal::entityQuery('taxonomy_term');
    $query->condition('vid', "tags");
    $tids = $query->execute();
    $terms = \Drupal\taxonomy\Entity\Term::loadMultiple($tids);

If you want to get several vocabulary, use OR condition like that.
    $query_or->condition('vid', "tags");
    $query_or->condition('vid', "test");
    $query->condition($query_or);

Get Taxonomy name
      $name = $term->toLink()->getText();

Create link to the term
      $link = \Drupal::l($term->toLink()->getText(), $term->toUrl());

NOTE : I don't know it is the best way, but it's working

 

Comments

slivorezka (not verified)

Mon, 11/07/2016 - 10:10

    $tree = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree('tags', $parent = 0, $max_depth = NULL, $load_entities = FALSE);

$terms = \Drupal::service('entity_type.manager')->getStorage("taxonomy_term")->loadTree('nieuws_category', $parent = 0, $max_depth = NULL, $load_entities = FALSE);

prada wallet
moncler
salomon shoes
air vapormax
nike air max 97
coach
michael kors handbags
coach outlet
nike air max 97
christian louboutin
nike kd
ferragamo
bvlgari
ray ban glasses
pandora charms
adidas nmd womens
Pandora Bracelet
Hermes Belts
adidas ultra uncaged
nike air max
salomon skis
curry 4 shoes
jimmy choo trainers
goyard backpack
moncler jacket
adidas superstar shoes
yeezy boost 350 v2
hermes belt men
red bottoms
lebron james shoes
jordan 11 space jam
nike air max 90
air max 90
christian louboutin
jordan space jams
ralph lauren polo shirts
new balance
skechers uk
yeezy boost 350
longchamp
chrome hearts pendant
pandora,pandora charms
harden shoes
ultra boost mens
puma fenty
air max 90
nike air max 95
nike air max 97
goyard wallet
chrome hearts bracelet
fitflops uk
swarovski necklace
fitflop sale
pandora
ecco
ralph lauren polo shirts
pandora bracelet
adidas ultra boost
pandora earrings
pandora jewelry official site
stephen curry shoes
moncler coat
salvatore ferragamo
ray ban
yeezy
air jordan
michael kors purse
jordan retro
kyrie irving shoes
nike air max 270
air jordan
valentino sneakers
birkenstock
skechers women
moncler coat
nike air huarache
burberry
mbt mens shoes
kate spade handbags
lacoste shirts
huarache
uggs for women
curry 4 shoes
pandora charms
yeezy boost 350 v2
kate spade purses
nike air max 90
oakley
mulberry handbags
polo ralph lauren
moncler
uggs for women
supreme shirt
ray ban sunglasses
vapormax
moncler jacket womens
ed hardy clothing
Adidas Yeezy
chrome hearts
burberry bags
kate spade handbags
nike air max 97
cartier glasses
pandora jewelry
longchamp bag
mcm handbags
true religion
mont blanc sale
supreme shoes
celine,celine bag
adidas yeezy
adidas nmd r1
air max
fitflop
asics womens shoes
air max 95 mens
nike air max 270 flyknit
lebron shoes
north face coats
mcm
swarovski
mulberry
nike air max 95 mens
uggs for women
prada bags
ugg
nike air vapormax
kd 10
nike air max 270
pandora jewelry
ralph lauren polo shirts
nike air max 97
pandora jewelry
oakley
salomon shoes
nike air vapormax
fitflop sale
ray ban prescription sunglasses
adidas
true religion jeans men
yeezy shoes
pandora bracelet
skechers boots
barbour jacket
birkenstock shoes
adidas nmd
barbour
kyrie irving shoes
burberry handbags
Salomon xa pro 3d
balenciaga sneakers
kd 11
louboutin
jordan shoes
asics
north face coats
yeezy boost
balenciaga sneakers

gaurav (not verified)

Thu, 01/12/2017 - 16:45

I have got the list of terms but i want to print these terms in my views block  twig file.
so how can i do that ?

 

Add new comment