Metafields richtext, doesn't display all values

Solved

Metafields richtext, doesn't display all values

pavel_shopio24
Shopify Partner
5 0 0

I need to display all values from richtext, e.g.:

Dieser Artikel fällt kleiner aus
Wir empfehlen Dir, diesen Artikel eine Nummer größer zu kaufen

My code is: 

 {{ product.metafields.product.passform }} 

Displays this: 
{"type":"root","children":[{"type":"paragraph","children":[{"type":"text","value":"⚠ "},{"type":"text","value":"Dieser Artikel fällt kleiner aus\n","bold":true},{"type":"text","value":"Wir empfehlen Dir, diesen Artikel eine Nummer größer zu kaufen"}]}]}

 

I found the solution {{ product.metafields.product.passform | metafield_tag }}

But it doesn't transfer text from the new line 

 

How to display values with new lines?

 

 

Accepted Solution (1)

MiracleWebsoft
Shopify Partner
38 4 11

This is an accepted solution.

You need to access like this

{{ product.metafields.product.passform | metafield_tag  }}

- Your Coffee Tip can create magic in coding


- Seeking a Shopify Certified Developer? Contact us Shopify Verified partners



If I managed to help you then, don't forget to Like it and Mark it as Solution! 

View solution in original post

Replies 3 (3)

MiracleWebsoft
Shopify Partner
38 4 11

This is an accepted solution.

You need to access like this

{{ product.metafields.product.passform | metafield_tag  }}

- Your Coffee Tip can create magic in coding


- Seeking a Shopify Certified Developer? Contact us Shopify Verified partners



If I managed to help you then, don't forget to Like it and Mark it as Solution! 

omarhussain
Shopify Partner
32 5 7

To display the values with new lines from the RichText data, you can use the HTML <br> tag to create line breaks. Since the data you have is in a structured format, you'll need to convert it to HTML with line breaks before displaying it.

 

Here's how you can achieve

 

{{ product.metafields.product.passform | metafield_tag | replace: '\n', '<br>' | raw }}

 

 

 

pavel_shopio24
Shopify Partner
5 0 0

the part of code after metafield_tag doesn't work