Skip to main content
added 22 characters in body
Source Link
Kevin
  • 28k
  • 12
  • 95
  • 196

there is no way of templating the content in the following way

Sure there is.

You can create a block--block-type.html.twig template that corresponds to this particular block type.

<div class="row">
   <div class="col-md-12">
     {{ content.field_one }}
   </div>
</div>
<div class="row">
  <div class="col-md-12">
     {{ content.field_two }}
  </div>
</div>

Where field_one etc is the name of a field attached to the block type. Another common thing I have seen with this (Bootstrap) is that some people add fields to the block type denoting the column width. IE a select field with Small, Medium, Large, who's keys are col-sm-12, col, md-12, col-lg-12 and what have you.

<div class="row">
   <div class="{{ content.field_col_one_size }}">
     {{ content.field_one }}
   </div>
</div>
<div class="row">
  <div class="{{ content.field_col_two_size }}">
     {{ content.field_two }}
  </div>
</div>

This would mean you need to display the field with its key value, and override its template:

field--field-col-one-size.html.twig

{% for item in items %}
  {{ item.content }}
{% endfor %}

I don't know what you mean by 'calling page' though, or why that is necessary.

I haven't seen the rest of the code, but you can also render using your own theme function and twig template too in a custom controller.

To be honest, a lot of this is upfront strategy and planning when architecting content types, block types, and paragraph types or other content entities. It helps you roadmap templates and how to handle how and what will render their output.

there is no way of templating the content in the following way

Sure there is.

You can create a block--block-type.html.twig template that corresponds to this particular block type.

<div class="row">
   <div class="col-md-12">
     {{ content.field_one }}
   </div>
</div>
<div class="row">
  <div class="col-md-12">
     {{ content.field_two }}
  </div>
</div>

Where field_one etc is the name of a field attached to the block type. Another common thing I have seen with this (Bootstrap) is that some people add fields to the block type denoting the column width. IE a select field with Small, Medium, Large, who's keys are col-sm-12, col, md-12, col-lg-12 and what have you.

<div class="row">
   <div class="{{ content.field_col_one_size }}">
     {{ content.field_one }}
   </div>
</div>
<div class="row">
  <div class="{{ content.field_col_two_size }}">
     {{ content.field_two }}
  </div>
</div>

This would mean you need to display the field with its key value, and override its template:

field--field-col-one-size.html.twig

{% for item in items %}
  {{ item.content }}
{% endfor %}

I don't know what you mean by 'calling page' though, or why that is necessary.

I haven't seen the rest of the code, but you can also render using your own theme function and twig template too in a custom controller.

To be honest, a lot of this is upfront strategy and planning when architecting content types, block types, and paragraph types. It helps you roadmap templates and how to handle how and what will render their output.

there is no way of templating the content in the following way

Sure there is.

You can create a block--block-type.html.twig template that corresponds to this particular block type.

<div class="row">
   <div class="col-md-12">
     {{ content.field_one }}
   </div>
</div>
<div class="row">
  <div class="col-md-12">
     {{ content.field_two }}
  </div>
</div>

Where field_one etc is the name of a field attached to the block type. Another common thing I have seen with this (Bootstrap) is that some people add fields to the block type denoting the column width. IE a select field with Small, Medium, Large, who's keys are col-sm-12, col, md-12, col-lg-12 and what have you.

<div class="row">
   <div class="{{ content.field_col_one_size }}">
     {{ content.field_one }}
   </div>
</div>
<div class="row">
  <div class="{{ content.field_col_two_size }}">
     {{ content.field_two }}
  </div>
</div>

This would mean you need to display the field with its key value, and override its template:

field--field-col-one-size.html.twig

{% for item in items %}
  {{ item.content }}
{% endfor %}

I don't know what you mean by 'calling page' though, or why that is necessary.

I haven't seen the rest of the code, but you can also render using your own theme function and twig template too in a custom controller.

To be honest, a lot of this is upfront strategy and planning when architecting content types, block types, paragraph types or other content entities. It helps you roadmap templates and how to handle how and what will render their output.

Source Link
Kevin
  • 28k
  • 12
  • 95
  • 196

there is no way of templating the content in the following way

Sure there is.

You can create a block--block-type.html.twig template that corresponds to this particular block type.

<div class="row">
   <div class="col-md-12">
     {{ content.field_one }}
   </div>
</div>
<div class="row">
  <div class="col-md-12">
     {{ content.field_two }}
  </div>
</div>

Where field_one etc is the name of a field attached to the block type. Another common thing I have seen with this (Bootstrap) is that some people add fields to the block type denoting the column width. IE a select field with Small, Medium, Large, who's keys are col-sm-12, col, md-12, col-lg-12 and what have you.

<div class="row">
   <div class="{{ content.field_col_one_size }}">
     {{ content.field_one }}
   </div>
</div>
<div class="row">
  <div class="{{ content.field_col_two_size }}">
     {{ content.field_two }}
  </div>
</div>

This would mean you need to display the field with its key value, and override its template:

field--field-col-one-size.html.twig

{% for item in items %}
  {{ item.content }}
{% endfor %}

I don't know what you mean by 'calling page' though, or why that is necessary.

I haven't seen the rest of the code, but you can also render using your own theme function and twig template too in a custom controller.

To be honest, a lot of this is upfront strategy and planning when architecting content types, block types, and paragraph types. It helps you roadmap templates and how to handle how and what will render their output.