## How can I print the vocabulary name instead of the referenced term in a node template?

Let’s say I have a content type article with a field “taxonomy”.

The vocabulary is “fruits”.

The terms are “apple”, “orange”, “bananas”

The article belongs to “orange”.

I can easily print in my twig template the term of the article :

{{ content.field_taxo_fruit }} 

Result is “orange”.

But I don’t find an easy way to print the vocabulary : “fruits”.

On an other project, I used views field and I used “rewrite result”. But here, I use twig template like node--article--teaser.html.twig

## Create a template file just for the first level of taxonomy terms of a vocabulary

I need to create a template file just for the parents of taxonomy terms.

First of all I don’t know if the same as drupal 7 in 8 I should write this code in template.php file or not.

In the second place, I don’t know what does loadParents($tid) return if the term does not have any parent. In the third place, I don’t know if I must create page_taxonomy_term_cat.html.twig to use. function THEMENAME_theme_suggestions_page_alter(array &$  suggestions, array $variables) {$  tid = \Drupal::routeMatch()->getRawParameter('taxonomy_term');    $parent = \Drupal::entityManager()->getStorage('taxonomy_term')->loadAllParents($  tid);    if (is_null($parent)) {$  suggestions[] = 'page_taxonomy_term_cat';    } } 

plese help me with these three questions

## 8 – Set value on a new term based on a vocabulary custom field

I want to set the value of a field of a term based on a custom field set on the vocabulary. Basically if the vocabulary promote_to_index field is checked I want to the field_index_page of the term checked.

I understand I have to write a hook like but I don’t understand how to get the value of the vocabulary custom field

function polaris_drupal_taxonomy_form_alter(&$form, FormStateInterface &$  form_state, $form_id) { switch ($  form_id) {      case 'taxonomy_term_category_form':     case 'taxonomy_term_article_type_form':     case 'taxonomy_term_main_purpose_form':     case 'taxonomy_term_tags_form':     case 'taxonomy_term_content_partnership_form':     case 'taxonomy_term_traffic_source_form':     case 'taxonomy_term_client_form':       \$  form['field_index_page']['widget']['value']['#default_value'] = true;   } } 

## How to get the vocabulary terms for the current language

How do I programmatically get all the terms within a vocabulary for the current language?

This is a similar question to Get translated term name, but not for a single term, but for the entire tree.

## DDD – Translating Ubiquitous Language Vocabulary Across Bounded Contexts

One of the guidelines around building ubiquitous languages is that there should be one per bounded context.

In a domain that has more than one bounded context, and therefore more than one ubiquitous language, how should you deal with vocabulary that is different in each context, but related to each other with respect to the entire domain?

For example, objects in our domain contain a property that dictates the object’s identity, but constraints within each bounded context restrict ubiquity in both implementations, and these could not easily be circumvented…

// Implemented in one bounded context object Customer {   id: guid }  // Implemented in another bounded context object Customer implements Identity {     identity: Identifier } 

Note that id and identity in each bounded context refer to the same thing, but their names and data types differ.

How do I achieve ubiquity across these implementations when referring to this from the perspective of the domain as a whole, and is there a suitable method for translating between the two?

## How do I import product category based on taxonomy vocabulary?

I have a products catalog based on taxonomy vocabulary, as advised the term reference field is on the product content type.

Products imports are working fine, but when I try to import product displays the mapping for term reference (Category vocabulary)does not appear in the target list.

I’m using Feeds 7.x-2.0-alpha8, Commerce Feeds 7.x-1.3, Commerce Kickstart 7.x-1.19 and Drupal Core 7.22

## Drupal 7 Commerce KickStart – Add A Field in Product Variation that lets user Choose From A List of Terms in A Specific Vocabulary

I want to add a field in product variation that lets user choose from a list of terms in a specific vocabulary. For example, I have a vocabulary of “Pizza Recipes”. The terms in the vocabulary will be an option in a select drop down of my content. How will I do that?

Example:

The terms in the vocabulary must appear as options in a select drop down. I don’t know what field type should I use. Is it a term reference or entity reference or what? I tried both but it doesn’t give me what I desire.

## Expected number of times of choosing a word out of a given vocabulary when words are grouped into overlapping bins

Two players (player C and player G) are playing a (modified) word guessing game. Both players share the same vocabulary $$V$$ and words in $$V$$ are grouped into $$K$$ bins, denoted as $$b_1$$, $$b_2$$, …, $$b_{K}$$. Furthermore, we know that $$b_{i} \subset V$$, $$\cup_{i=1}^{K} b_i = V$$. Note that those bins may be overlapping and thus there may exist some case where $$b_i \cap b_j \neq \emptyset$$ for $$i \neq j$$.

The interaction protocol is described as follows:

1. Player C uniformly chooses a word $$w$$ from the vocabulary $$V$$. Player G does not know which word $$w$$ is.

2. Player G chooses one bin and asks Player C whether his/her chosen word $$w$$ is in the bin. If it is, the game ends. Otherwise, Player G will choose another bin.

Questions: What is the best bin choosing order and what is the expected number of times of choosing the bin, according to the best possible order?

Example:

Suppose we have a vocabulary consisting of ten words $$V = \{w_1, w_2, …, w_{10} \}$$ and three bins $$b_1 = \{w_1, w_2, …, w_5\}$$, $$b_2 = \{w_6, w_7 \}$$, and $$b_3 = \{w_8, w_9, w_{10} \}$$.

One possible bin choosing order is $$b_1 \rightarrow b_3 \rightarrow b_2$$ and the expected number of times of choosing the bin is $$\frac{1}{2}*1 + \frac{1}{2}*\frac{3}{5}*2 + \frac{1}{2}*\frac{2}{5}*\frac{2}{2}*3 = 1.7$$. I suspect this is the best bin choosing order but how can we prove this result?

Notes:

In this problem, we do NOT have the additional knowledge that all bins are non-overlapping, compared to a related problem.

Thanks.

## How to give users access by vocabulary and show the links in admin_toolbar according to the permission?

I have tried to give the user access to vocabulary granularly, currently it is only possible to give access to use vocabularies and terms and I only want certain roles to only manipulate certain vocabularies, I do not want any role to create new vocabularies.

I have tested with the vppr module and apparently it does not work well with D8. I also want that if I give access to a certain vocabulary this can be accessed through the menu (admin_toolbar).

Does anyone have any ideas or references on how to implement this operation?

Greetings.

## How to translate vocabulary name?

Drupal 8 installation in English, German lang was added and set as default, vocabularies are set to English (no result even they are in German too), terms are set to German by default, Content translation, Configuration translation and Interface translation are enabled.

On /admin/config/regional/content-language “Content” and “Taxonomy term” are enabled (all fields). There is nothing about vocabularies.

On /admin/structure/taxonomy Operations have a link “Translate” per vocabulary and added translation through is saved. But switching language with language switcher do not show vocabularies name translated – table columns names are translated and shown properly (and any UI string in table) just not category name itself. I clear cache after translation was added.