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);

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 ?

 

wwwe (not verified)

Sat, 12/01/2018 - 09:42

    `        
<H1><a href="http://www.yeezyboost350v2.org.uk" title="yeezy boost 350 v2"><strong>yeezy boost 350 v2</strong></a></H1>            
<H1><a href="http://www.russellwestbrookshoes.us" title="westbrook shoes"><strong>westbrook shoes</strong></a></H1>            
<H1><a href="http://www.stephencurry-shoes.us.com" title="stephen curry shoes"><strong>stephen curry shoes</strong></a></H1>            
<H1><a href="http://www.louboutinshoes.uk" title="louboutin shoes"><strong>louboutin shoes</strong></a></H1>            
<H1><a href="http://www.patriotsjerseys.us.com" title="patriots jerseys"><strong>patriots jerseys</strong></a></H1>            
<H1><a href="http://www.kobeshoes.uk" title="kobe byrant shoes"><strong>kobe byrant shoes</strong></a></H1>            
普通H1标签              
<H1><a href="http://www.nikeairforce1.us.com"><strong>nike air force 1</strong></a></H1>            
<H1><a href="http://www.michaelkorshandbags.net.co"><strong>michael kors handbags</strong></a></H1>            
<H1><a href="http://www.cartierbracelet.us"><strong>cartier bracelet</strong></a></H1>            
<H1><a href="http://www.offwhiteclothing.us.com"><strong>off white clothing</strong></a></H1>            
UBB            
[url=http://www.louboutinshoes.uk][b]louboutin shoes[/b][/url]            
[url=http://www.nikehyperdunk2017.us.com][b]nike hyperdunk 2017[/b][/url]            
[url=http://www.nikebasketballshoes.us.com][b]nike basketball shoes[/b][/url]            
[url=http://www.adidas-pureboost.us.com][b]adidas pure boost[/b][/url]            
A标签            
<a href="http://www.adidassuperstar.us.com"><strong>adidas superstar</strong></a>            
<a href="http://www.lebron-soldier11.us.com"><strong>nike lebron 11</strong></a>            
<a href="http://www.nike-airmax90.uk"><strong>nike air max 90</strong></a>            
<a href="http://www.adidasnmdrunner.us.com"><strong>adidas nmd</strong></a>            
裸链            
http://www.yeezys.us.org            
http://www.yeezy-shoes.ca            
http://www.yeezy-shoes.org            
http://www.yeezy-shoes.org.uk            

 

wwwe (not verified)

Sat, 12/01/2018 - 09:42

goyard handbags

michael kors purses

ferragamo belt

yeezy boost

yeezy

adidas yeezy

jordan 11

yeezy boost 350

fila sneakers

nike epic react

nike air max 2019

rolex replica

adidas superstar

yeezy boost 350

kevin durant shoes

lacoste

adidas crazy explosive

golden goose outlet

paul george shoes

cheap jordans

fila shoes

nike cortez men

hermes outlet online

coach outlet online

kd shoes

goyard bags

nike huarache

kd 11

air jordan

lebron 15 shoes

nike cortez

air jordan 13

yeezy boost 350

vapormax

vans outlet

curry 4

yeezy shoes

bape hoodie

adidas stan smith

mbt shoes

nike shox

nike kd 11

lacoste outlet

ralph lauren uk

golden goose sneakers

air yeezy

michael kors handbags outlet

nfl store

yeezy boost 700

yeezy boost 350

off white clothing

golden goose sneakers

goyard handbags

michael kors outlet

coach outlet

goyard

coach factory outlet

yeezy boost

tory burch outlet

michael kors outlet

nmd

http://www.kobeshoes.uk

longchamp

goyard st louis tot

chrome hearts online

gucci belt

yeezy boost 350

kyrie 4 shoes

yeezy boost 350 v2

off white

westbrook shoes

adidas iniki

100% real jordans for cheap

iniki

yeezys

jordan shoes

calvin klein outlet online

vapor max

yeezy boost 350 v2

kyrie shoes

canada goose

golden goose outlet

off white

gucci belts

curry 4 shoes

caterpillar boots

hermes belt

jordan 4

jordans

nike sneakers

lebron 16 shoes

links of london outlet store

lacoste polo shirts

longchamp

james harden shoes

air force 1

zx flux

jordan sneakers

kobe 9

michael kors outlet online

michael kors

birkin bag

basketball shoes

nike air max

yeezy boost

adidas outlet

lebron 15

crazy explosive

off white nike

goyard bag

adidas shoes online

louboutin shoes

cheap jordans

kobe 11

adidas outlet online

nike roshe

michael kors factory outlet

lacoste outlet

balenciaga triple s

jordan shoes

timberland boots

nba jerseys

golden goose outlet

balenciaga

nike lebron 16

Kanye West shoes

retro jordans

nike hyperdunk

cheap nfl jerseys

adidas stan smith shoes

nike shoes

golden goose outlet

russell westbrook shoes

kyrie irving shoes

nike air max 2017

valentino

adidas eqt

lebron shoes

yeezy shoes

jordan 13

adidas tubular

yeezy boost

hermes belt

adidas shoes outlet

off white hoodie

yeezy shoes

jordans

longchamp handbags

chrome hearts

tory burch sandals

fila shoes

adidas yeezy

golden goose

michael kors outlet

off white jordan 1

lebron james shoes

curry 5

michael kors outlet

moncler outlet

cheap mlb jerseys

christian louboutin

yeezy

hermes online shop

fake rolex

jordans

michael kors handbags

nike huarache

michael kors outlet online

golden goose sneakers

ferragamo belts

kd shoes

balenciaga shoes

cheap jordans

longchamp outlet

nike air force 1

reebok outlet

fila

air jordan

hermes handbags

nike air max 90

moncler jacket

yeezy boost

kd 11 shoes

lebron 16

pure boost

longchamp handbags

michael kors handbags

ralph lauren uk

mbt shoes outlet

jordan 6

yeezy shoes

ferragamo belts

mlb jerseys

cheap jordans

valentino shoes

red bottoms

lebron 11

adidas gazelle

kobe 11

jordan retro

michael kors outlet

hogan outlet

hermes handbags for sale

jordan retro 12

michael kors handbags

fila

yeezy

links of london

adidas yeezy

asics running shoes

lacoste polo

kobe basketball shoes

stephen curry 5

nike air max

golden goose sneakers

kd 10

air max 270

nfl jerseys

adidas ultra boost uncaged

balenciaga shoes

nike roshe run

michael kors

off white hoodie

air max 90

hogan outlet online

nhl jerseys

adidas nmd

hermes handbags

nike polo

goyard wallet

ysl

nike sneakers for men

longchamp

kyrie 3

kobe shoes

golden goose

coach outlet online

yeezy boost 350 v2

nike epic react

adidas tubular

birkin bag

kyrie 4

red bottom heels

off white

moncler jackets

fila

birkin bag

kobe 9

jordan shoes

adidas tubular

yeezy 500

lacoste polo

coach handbags

replica rolex

lebron 16

curry 5

longchamp outlet

lebron 10

tory burch

michael kors outlet

golden goose outlet

golden goose

nike air max

yeezy shoes

timberland outlet

louboutin shoes uk

fitflops sale clearance

air max 2019

off white clothing

yeezy 700

mbt shoes online

yeezy boost 350 v2

longchamp bags

golden goose

nike shox for men

balenciaga

yeezy boost 350

nike flyknit racer

adidas ultra

michael kors outlet store

fila disruptor

kd 11

kobe shoes

chrome hearts

adidas nmd runner

michael kors outlet online

ysl handbags

fake rolex

lebron 16

yeezy boost 350

nike air huarache

coach factory outlet

coach outlet sale

nike air max

pandora jewelry

balenciaga

air jordan 4

nike basketball shoes

nmd

fitflops

kate spade handbags

curry 4

yeezy shoes

cheap nba jerseys

adidas ultra boost

hermes belts for men

adidas nmd

michael kors handbags

air max 2018

fila shoes

longchamp bags

adidas shoes

adidas stan smith sneakers

offwhite

yeezy boost

nike jordans

air max

lacoste polo

nike react

adidas stan smith

adidas superstars

coach outlet

adidas nmd r1

jordan shoes

hermes birkin

lebron shoes

supreme hoodie

chrome hearts online

adidas zx flux

nike polo shirts

yeezy boost 350

fila

vans shoes

harden shoes

yeezy 500

michael kors outlet

goyard handbags

nike air force

fake rolex watches

yeezy boost 500

goyard bag

longchamp bags

adidas pure boost

chrome hearts

pandora bracelet

nike react

coach outlet

adidas nmd

nike air max 2018

golden goose

coach outlet sale

hermes belt

moncler jackets

nike foamposite

goyard bags

michael kors handbags

off white shoes

tory burch shoes

converse outlet

hermes bags

calvin klein outlet

reebok shoes

michael kors outlet

longchamp handbags

nike air max 270

canada goose UK

golden goose

adidas tubular shadow

off white x jordan 1

lacoste online shop

yeezy boost

adidas yeezy

michael kors outlet online

lebron 16 shoes

jordan 12

off white clothing

goyard

ferragamo belt

jordan retro 6

balenciaga shoes

kobe sneakers

yeezy shoes

jimmy choo shoes

jordan shoes

ultra boost

adidas ultra boost

kobe byrant shoes

cheap nba jerseys

michael kors uk

red bottom shoes

chrome hearts online

yeezy boost 350

air jordans

adidas yeezy boost

coach outlet

bape hoodie

nike sneakers for women

balenciaga sneakers

yeezy boost 350 v2

yeezy boost 350 v2

jordan 11 retro

kd shoes

fila shoes

asics shoes

adidas eqt support

kobe shoes

off white shoes

michael kors handbags

nike max

converse outlet store

nike flyknit

birkin bag

michael jordan shoes

baseball jerseys

cat boots

polo ralph lauren

yeezys

retro jordans

hermes handbags bag

stephen curry 5

Add new comment