1

I have created a view that creates pages, each page display the terms of taxonomy of a vocabulary and their articles, how can i link the articles to those pages ?

For example :

  • I have the Vocabulary Food : for which i generated a page /articles/apple
  • Food has the terms of taxonomy : 'Apple'
  • The article : 'Learn about appels' has the term of taxonomy 'Apple'

How do i display a link or breadcrumb for the users on the article 'Learn about appels' that redirect them to the list of 'Food' /articles/apple ?

p.s : i have many many articles, terms of taxonomy and vocabulary.

2

The default breadcrumb implementation is based on the path.

If you use Pathauto to generate aliases (with a pattern like /articles/[node:field_food_category:entity:name]/[node:title]), so that the resulting alias is /articles/apple/learn-about-apples, then the breadcrumb should just work.

The active menu trail will not, but you can use a module like https://www.drupal.org/project/menu_trail_by_path for that.

A custom link will have to get the term and its URL, you can get that in preprocess_node() and then print it out in the template wherever you want.

I don't now how you handle content in different vocabularies, if it's a separate node type, or using different category fields or even a single one), based on that it will be more or less complicated to define the pathauto pattern(s), but you could always set up a custom token like [node:my_custom_category_path] to deal with that.

I'd suggest you ask more specific questions if some things are not clear yet as this gets too longer otherwise

  • I've used pathauto like you suggested and it works fine, thank you – usethe23 Jan 31 '17 at 13:06
1

Using views...

  • Make a view block
  • Add a field of your terms
  • Edit that field's multiple display settings and uncheck "display multiple values in the same row"
  • Rewrite that field with Learn more about <a href="articles/{{Your replacement pattern}}">{{Your replacement pattern}}</a>
  • Include your view block on all content types of article.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.