Showing posts with label paragraph fields render. Show all posts
Showing posts with label paragraph fields render. Show all posts

Thursday 17 June 2021

How to render nested paragraph field in drupal 8 paragraph twig?

It's a very easy way to render nested paragraph fields, we are going to explain with 2 methods for link field data.

Method 1: Suppose your paragraph(entity reference revisions) name is 'simple_card', so your file name will be "paragraph--simple-card.html.twig" and we have to render inner paragraph(entity reference revisions) link field data, so our approach will be...

{% for item in content.field_p_link['#items'] %}

{{ item.entity.field_link.uri }}

{% endfor %}


Method 2: Our second method will be direct one line code for this inner 'field_link' field data is...

{{ content.field_p_link['#items'].entity.field_link.uri }} 


// here field_p_link is the first paragraph revision field and field_link is a nested paragraph field.

Imp: Other text fields simply render by 

          {{ content.field_p_link['#items'].entity.field_first_name.value}} 


Note: If have any suggestions or issue regarding 'How to render nested paragraph field in drupal 8 paragraph twig?' then you can ask by comments. 

Wednesday 5 September 2018

Paragraph fields render in drupal 8 Node Twig template.

If we want to load paragraph entity fields on node twig template. It's easy to load paragraph entity, Please have a look..

{# call to paragraph entity fields on node twig #}

{{ node.field_professional_features.entity.field_professional_services_name.value }}
 // here `field_professional_features` is the content type field and `field_professional_services_name` is the related paragraph field..

{{ node.field_professional_features.entity.field_professional_services_summ.value }}
  // here `field_professional_features` is the content type field and `field_professional_services_summ` is the related paragraph field..

// here we are calling paragraph image field..

{% for key, image in node.field_professional_features %}
// here `field_professional_features` is the content type field..
{%if image.entity %}
{% set paragraph = image.entity %}
{% set file = paragraph.field_professional_services_imag.entity %}
 // here `field_professional_services_imag` is the related paragraph field..
{% set uri = file_url(file.uri.value) %}

<img src="{{ uri }}" alt="{{ paragraph.name.value }}" />

{% endif %}
{% endfor %} 



Note: If have any suggestions or issue regarding 'Paragraph fields render in drupal 8 Twig template.' 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...