Showing posts with label taxonomy custom fields render on file. Show all posts
Showing posts with label taxonomy custom fields render on file. Show all posts

Tuesday 7 August 2018

How to render fields on Taxonomy twig templates?

It is easy to call/render taxonomy fields on taxonomy template. We just have to create template file according to vocabulary machine name like 'application landing page' is taxonomy and machine name will be 'application_landing_page', but our template name will be 'taxonomy-term--application-landing-page.html.twig' as per Drupal 8(Symphony) Syntax.

and we will call/render fields like..


Term id: {{ term.id }}  // term id

Term Url: {{ url }}  // current page url

Term Title: {{ term.label }}  // term title

Term Image: {{ file_url(term.field_product_group_image.entity.uri.value) }}  // show url of product group image is the image field in taxonomy

Term Description/body: {{ content.description }}

Term Link field: {{ term.field_link.0.url }}

Term Link Title field: {{ term.field_link.0.title }}

Term custom field: {{ content.field_machine_name }}


If we want to check any field value exist or not then we are giving an example like we have field 'line of business' so machine name will be line_of_busines and we will check by..

{% if content.field_line_of_busines is not empty %}

{{ content.field_line_of_busines }}

{% endif %}



Note: If have any suggestions or issue regarding 'How to render fields on Taxonomy twig templates' then you can ask by comments.

How to resolve max execution time error in drupal ?

When you found error regarding 'max_execution_time' exceed, then you can follow steps for resolve this error: Steps:   You can put t...