Questions tagged [taxonomy-terms]

"Taxonomy" refers to Drupal's content classification mechanism, organised into vocabularies and terms.

Filter by
Sorted by
Tagged with
4
votes
2answers
3k views

Programmatically add a taxonomy term as entity reference in a custom entity

I'm really struggling to add a taxonomy_term as an entity reference to a custom entity I've created programmatically. Here is my configuration based on BaseFieldDefinition (the name of the vocabulary ...
4
votes
2answers
1k views

How do I group taxonomy by hierarchy, not node?

I am using Drupal 7 and Views. I'm trying to use the generic Taxonomy/Term view and get a grouping I don't want. I want this: Taxonomy 1: Node A Node B Taxonomy 2: Node B Node C (Notice Node B ...
3
votes
2answers
4k views

How to do a custom taxonomy breadcrumb

I'm using Drupal 8.3.0-beta1 and I need to write a custom module to customize breadcrumbs in some cases. On of this cases consists in customizing the breadcrumb in path taxonomy/term/% but with my ...
2
votes
3answers
10k views

How to print taxonomy terms field in node templates?

How can I display node taxonomy terms field in node templates of Drupal 8? We do this in Drupal 7 by add this code to node.tpl.php file: print render($content['field_tags']); I tried adding the ...
2
votes
3answers
10k views

Need a list of terms from a vocabulary machine name

How can I get the terms of a vocabulary using vocabulary machine name. I have used the following code, although it works for me but I am looking for efficient methods. $vocabulary = ...
14
votes
1answer
5k views

Programmatically create taxonomy term

How would you programmatically create taxonomy term? I wish to bulk create some in a custom module.
12
votes
4answers
10k views

How to get all node entities tagged with a specific term?

For a given taxonomy term in D8, is there any API function/method that returns all node entities that reference it?
9
votes
4answers
18k views

Get the vocabulary ID by term or node

I am going to check whether a term belongs to a designated vocabulary. Which function is used to get vocabulary by term or node?
8
votes
3answers
10k views

Check if current page is taxonomy term

How can I check if the current page is a taxonomy term page, similarly to what done with the following code used to check if the current page is the front page? if (drupal_is_front_page()) { // The ...
6
votes
3answers
4k views

How to grant a role permission to edit terms in a specific vocabulary [closed]

Is there a way/module to grant a role permission to list and edit terms in a specific vocabulary?
5
votes
1answer
4k views

Show newest nodes for each taxonomy term in Views

A block with taxonomy terms and an overview of the newest nodes for each taxonomy term. Every news sites uses this idea. Business: Article 1, Article 2 Technology: Article 1, Article 2 Sports: ...
4
votes
4answers
696 views

Should I change multiple text fields values via MySQL or is there any other preferable way?

The site has a content type and this content type has two fields: Text Field Term Reference Field There are thousands of nodes on this content type and I want to change some values (find/replace). ...
19
votes
4answers
21k views

How do I get the taxonomy term ID from its name?

The only function on the list of taxonomy.module functions that looks like it does what I want appears to be a private function (_taxonomy_get_tid_from_term). What function am I supposed to use if ...
8
votes
4answers
690 views

Is it acceptable to change the vid column of a term programmatically in the database?

I need to move some terms from one vocabulary to another by retaining all their data: translations, aliases, and node references. Is it acceptable to change its vid column value directly in the ...
6
votes
1answer
1k views

How to reference existing term if it exists or create new one if not exist via Inline Entity Form module?

I have a content type book and it has a taxonomy term reference field: author. I want to enter name and surname separately for each author on node add/edit page. Name and surname together will be the ...
6
votes
3answers
10k views

Get custom fields assigned to taxonomy

How to get custom fields assigned to taxonomy in Drupal 8. What I have done so far is: $contact_countries = \Drupal::service('entity_type.manager')->getStorage("taxonomy_term")->loadTree('...
3
votes
3answers
8k views

display a taxonomy terms as autocomplete using form API [closed]

I am writing my own module. I want to display a taxonomy terms as a autocomplete field in my form using form API. How can I do that? I am using Drupal7.
3
votes
1answer
619 views

Limit the creation of tags

I wish to create a taxonomy where the administrator users limit which terms can be tagged. Suppose I have a vocabulary containing the following terms: Football Golf Snooker I want the tag ...
2
votes
2answers
724 views

Using existing term reference field vs. creating new ones

I have 3 content types (blogs, photos, videos) that all reference the same "topic" vocabulary. When I add the term reference field to each content type I can either create a new field "...
1
vote
5answers
5k views

Override taxonomy term path with Views

I need to override by views my hierarchical taxonomy term paths: www.example.com/[vocabulary name] www.example.com/[vocabulary name]/term1 www.example.com/[vocabulary name]/term1/term2 www.example....
1
vote
3answers
108 views

For content, what are the differences between nodes and terms

I am debating whether to use nodes or terms to store a large amount of content in Drupal. There are a lot of similarities between nodes and terms in Drupal 8/9: Both can add any type of field. Both ...
1
vote
2answers
1k views

How to create Taxonomy Term using Services?

I've a vocabulary called Tags. I need to create Taxonomy terms under this vocabulary using REST service. So What is the JSON format to create taxonomy term. Similarly what is the JSON format to ...
1
vote
2answers
1k views

Limit the number of levels (depth) of a taxonomy vocabulary

I would like to limit the depth of a taxonomy vocabulary to a maximum number parent/child nestings. I would like my users to not be able to add at most 4 levels deep of taxonomy terms per tree. Is ...
4
votes
2answers
7k views

Custom template file for taxonomy term in drupal 7

I need to create only one tpl.php file for all taxonomy terms in my website. I know taxonomy_term_page.tpl.php will do the required function in Drupal6. For drupal 7 I had override the taxonomy-term....
3
votes
2answers
1k views

How do I redirect a taxonomy menu item to another path?

I have a taxonomy menu, and I want to redirect the page request from taxonomy/term/% to a custom path using a page callback function. How can I use a function to cause the redirect?
3
votes
2answers
1k views

Commerce - Views - Taxonomy - Add to cart issue

I am constructing an e-shop using Drupal Commerce. I've arranged my products in Categories and Subcategories using taxonomies and taxonomy-menu. All is nice till now. I also created a view, that ...
3
votes
1answer
1k views

A nice way to build a related content algorithm

I am making a custom D7 module which has a block that lists related nodes of the current node you're viewing. The relation is determined by Taxonomy terms (from 1 vocab). The complication is that the ...
3
votes
2answers
3k views

Theme specific taxonomy page

I cant seem to find a proper way to do this, I found ways for d5 but nothing on d7 so I am asking how can I edit a specific taxonomy page in d7?
2
votes
1answer
226 views

How to load a taxonomy term with case-sensitive?

I used this $this->termStorage->loadByProperties(['name' => 'test']); I got two terms: Test, test. I want to get only one: test This is working without case-sensitive: $this->...
2
votes
2answers
957 views

How can I display a taxonomy term's ancestral tree on a content page?

I am using Drupal 8. I have a hierarchical taxonomy vocabulary like this (simplified): Animals -Vertebrates --Fishes ---Butterflyfishes ----Chevron Butterflyfish On a taxonomy term's page, I ...
2
votes
2answers
7k views

Searching on Taxonomy terms with the Search API module?

I've been playing around with the Search API module for a little bit now, and it seems to be working fairly well, but I can't figure out how or why I am not able to search on terms even though they ...
2
votes
2answers
1k views

Overwrite Taxonomy Term page display settings with custom URL's

I would like to define the display settings of my Taxonomy term page. As I understand, this is possible by configuring the Taxonomy view provided by the Taxonomy module. However, I use custom URL'...
2
votes
3answers
4k views

Display the title of related nodes from taxonomy in block

How can I display the title of related news in a block shown in node page? For example, I create the content type "news", and add "news" nodes that have taxonomy terms taken from the same vocabulary; ...
2
votes
3answers
3k views

Get related node by taxonomy term?

Let's say I have two content types: Page and News. Both of them have a field called Tags which is taxonomy term. Let's say I tag a page and a news item with the term 'celebration'. When a user ...
2
votes
2answers
254 views

How to create a rule to combine the terms of 2 fields to create a new term and store it in a 3rd field?

I have a content type that has 3 term reference fields: Field A (required), which contains a single tag. Field B (required), which contains a single tag. Field C (not required), which contains a ...
2
votes
1answer
103 views

Drupal Views Exposed filter ( Taxonomy )

I have 3 fields ( Exposed filter ) 1 Country 2 State 3 City When a respective Country is selected in the 1st field, I want the second filter ( Dropdown or autocompete ) to display states of the ...
2
votes
1answer
461 views

How to send out email based on matching taxonomy terms in user profiles?

I'm using profiles 2 and have (one or many) taxonomy terms that can be selected by a specific profile type. I have a webform that also has this taxonomy term in the select list. When the webform is ...
2
votes
1answer
2k views

How to change the 'Name' label on term add/edit pages programmatically?

In Drupal 7 this was pretty easy. But now when I try to change the term name label on the term add/edit form all I find are protected methods. /** * Implements hook_form_alter(). */ function ...
1
vote
2answers
667 views

Link to create new node with taxonomy term from url already selected?

I need to make a link to create a new node. I need this link to appear on taxonomy term pages so I was going to put it in a block. Nodes can be tagged with taxonomy terms. How can I make it so the ...
1
vote
1answer
497 views

How to remove comma between taxonomy terms?

I style my taxonomy terms as boxes, so I don't need comma between them. Could somebody give me any advice?
1
vote
1answer
135 views

field collection - taxonomy term can't display

I used taxonomy term with field collection and taxonomy term can't display look this video https://www.youtube.com/watch?v=cEI1yDcJXT4
1
vote
1answer
1k views

Display content with Taxonomy on User and Content matching

I've got a specific content type. One field is a term reference field called "blog subject" in which a content author tags the node. Ok. Moving on to the end user. I added the same term reference ...
1
vote
1answer
677 views

Views, get data for parent term as well

I will try to keep the question simple and short. I have (Drupal 7): a Vocabulary "Country regions" (depth 1 level): Austria -Burgenland -Tyrol Belgium -Arlon -Liege -Namur ... a Content type "...
1
vote
1answer
2k views

How to associate programatically the translation of new term to the original existing term?

I've terms which share the same id in stored in field and I'd like to associate translation between them, so they're grouped on the same page at /taxonomy/term/%/translate So I've existing original ...
1
vote
1answer
1k views

Taxonomy vocabulary not showing up as existing field in new content type

I have 2 taxonomy vocabularies which I want to reference in new content types but I cannot see them under "add existing fields" when creating a new content type. Also tried referencing one taxonomy ...
1
vote
4answers
2k views

Programmatically create a taxonomy and attach a field to it

I created a vocabulary using the following code. $vocab = entity_create('taxonomy_vocabulary', array( 'name' => 'vocab_name', 'vid' => 'vocab_id', 'description' => 'description' )); $...
1
vote
1answer
1k views

Duplicated content shown in a view using a relationship

I am using a view that has a contextual filter ("Content: Has taxonomy term ID") and a relationship ("Content: Taxonomy terms on node"); for some reason, I keep getting duplicated content. In the view ...
1
vote
1answer
2k views

Disable or hide taxonomy term

What is best module to hide or disable or un-publish some terms in taxonomy or vocabulary like the way in the node tab of publishing in the back end
1
vote
1answer
427 views

Restrict node list in entity reference field based on node field

My "Article" nodes have a "domain" field that links to a taxonomy term. My "Article" nodes also have a repeatable "entity reference" field "more like this" that links to other "article" nodes. How ...
0
votes
1answer
109 views

Repeated elements in translations of a block view

I have a small problem when translating taxonomy terms inside of a block view. View configuration: Output: The translation is correct but the element quantity is incorrect. The idea is to have one ...

1
2
3 4 5
7