Drupal change display based on vocabulary - drupal

I need to have terms related to a specific vocabulary use a custom view I have set up.
For example: I have a vocabulary called "Book Categories" with terms under it such as Humor, History, etc. When navigating to a term page (taxonomy/term/7), I would like to display just the book title and a custom book-cover field. By default, Drupal displays node title, teaser, and links on all taxonomy term pages. The problem I am having is I would like terms that fall under the "Book Categories" vocabulary to use my custom view, and all other terms to use the default view.
Is there a way around this? Any help is appreciated.

You can clone default taxonomy view and change fields section as you like.
In PAGE SETTINGS->PATH remove "%" and add taxonomy number of your Book Category (like "7")
In contextual filter delete all filters.
This view then should override default view.
Hope this helps.

There is a new module called Taxonomy Views Integrator that seems like it does what you want to do. Try it.

Related

Add taxonomy terms list to homepage Drupal 8

Please help me to add taxonomy terms from custom taxonomy into home page. I have no idea how to do this as I'm coming from WordPress. In WordPress it is easy as calling get_terms(). I have following file as my home page: mytheme/templates/page--front.html.twig
I have more than one taxonomy type and all of them are going to queried in the home page.
How to query the taxonomy terms?
UPDATE:
I have created a new region called home_content in my theme.info.yml and I have created a view(block) for getting the taxonomy terms, added it to region in back-end and display it as {{page.home_content}}. It works but I have few questions.
I have fields for logo and text in the taxonomy. I want to list them too.
I need to customize the html. How can I do that?
Thanks for the support.
You don't really need to code anything
Create view with taxonomy terms required. Structure > Views > Create New View and add block view for taxonomy terms. User filter section to select specific terms or dictionaries. Save the view.
Go to Structure > Block Layout and insert block with your view into desired region. In visibility section, pages tab: type <front> in pages and select Show for the listed pages in order to display it on home page only.
Above steps will display your required terms on home page.
To copy and modify template(s) in your theme, follow the instructions on drupal.org: https://www.drupal.org/node/2358785

Drupal 7 - Term reference field: how to add new term?

I have some texonomies in my Drupal website. Some of them have additional fields. I have some fields of type Term reference in my content-types.
When I am creating a new node of a content-type, I would like to have the ability to add a new term to the taxonomy while I'm filling the form of the Content-Type (with an "add item" link/popup...).
I can do that if I use Entity Reference fields, but I cannot using Term reference field. Could you help me, please?
Thanks
UPDATE: I installed "Taxonomy access fix" module (https://www.drupal.org/project/taxonomy_access_fix) and it allows me to set capabilities per each taxonomy based on user role. Now I only need to add a new term to a Taxonomy on a form level using Term reference field (I canno use autocomplete because I need the user to see all possible values like with a dropdown).
Any help?
If you change your widget to the autocomplete widget, it will let you add new values.
I agree with #Dark FlameS, in fact we are using the autocomplete widget for some of our students to add types of trees in the biology lab and they tag each with the scientific name.
And since we dont know these scientific terms, we let them add taxonomy terms to the list.
Slight difference however, we use the module Autocomplete Deluxe. Works like magic for us.
You are able to see what taxonomy terms are already available by clicking into the text area.
And as you type a taxonomy term, you will see what other terms are similar. If a tag is new, it will be added. one thing, dont allow them to delete your tags. We learned this the hard way.
See the image below on what it looks like as you add a tag.
Above is what you will see when you are adding the taxonomy field in your content type, this is after you install the Autocomplete Deluxe module
Above is What the user sees when they add or select a taxonomy tag.

Drupal 7 - Add a wrapper around related nodes on Taxonomy term page

On a taxonomy term page, the taxonomy term info is shown first, followed by related nodes. I want to add a wrapper div around the related nodes (ex. class="related-nodes").
taxonomy-terms.tpl.php controls the display of the taxonomy term's fields, but I'm not sure how the nodes show up. I was thinking about making a node template for the taxonomy and doing something like render($content['nodes']). However, I'm not sure what the $content key would be for the related nodes.
One approach is to enable the Taxonomy term view display (is disabled by default).
In the view config, you can add classes by clicking in Settings of Format option.
Hope it helps.
Regards.

How to link taxonomy terms to view page?

I have enabled the taxonomy menu module and created a custom view from my vocabulary terms. However, the taxonomy menu terms are by default in the following structure [taxonomy_category]/[term-name] and link to the default taxonomy view.
How can I override the default taxonomy term links to link to my view page?I want to link the taxonomy term to this view page : products/term_id . I have downloaded taxonomy display module but either I didn't know how to configure it correctly or it doesn't work....
Anybody, who knows how can I change the links of the taxonomy terms?
Thanks!
there's a default (disabled) view that links to "taxonomy/term/term_id". You should enable that view and make the necessary changes to suit your needs.
Otherwise, you can create a view.
In the "Page Settings" you have the path.
Just put "/taxonomy/term/%" in the path.
It worked for me.

Drupal 7 list users with taxonomy term using Views and Pathauto

I am attempting to create a taxonomy term page to display users tagged with a vocabulary "expertise" and not having much luck.
I'm using pathauto to alias the taxonomy term pages with the following pattern: [term:vocabulary]/[term:name].
I then have a Views page for Users with the path set to /expertise/% and a contextual filter on "User: Expertise" (my taxonomy term field). The filter takes the default value of "Taxonomy term ID from URL" and validates as a taxonomy term from the "Expertise" vocabulary.
However, if I then go to (for example) /expertise/php I appear to be getting the standard Drupal taxonomy page rather than the View page setup and see no user results.
Any ideas how I can fix this? I have several taxonomies in use for both nodes and users so need to be able to distinguish between the vocabularies using the aliasing described above.
That's what a contextual filter does... it takes over every page.
I'm confused as to why you aliased the term pages at all... it seems like you don't want to dispaly them, so why not just forget about the alias and set the view page to the url you want it to be at?

Resources