Hi Shopify Community,
I’m working on a custom drawer accordion for my Shopify store and I’m having trouble displaying the content from metafield pages correctly. Here are the details:
Context:- Drawer Structure: I have a drawer (metaobject) is containing multiple metafields: acc_title, acc_icon, acc_page, and acc_rich. each of them contains a list of values
- Objective: I want to display content from these metafields in an accordion format, where each accordion section displays either content from acc_page or acc_rich, along with the title and icon.
Issue:- The acc_page metafield values are not displaying correctly. They show up as null in my debug output.
- The acc_rich, acc_title, and acc_icon metafields are working fine and displaying as expected.
Can you help me out please? what I’m doing wrong?
{%- if drawer != blank -%}
{% assign acc_titles = drawer.acc_title.value %}
{% assign acc_icons = drawer.acc_icon.value %}
{% assign acc_pages = drawer.acc_page.value %}
{% assign acc_rich_texts = drawer.acc_rich.value %}
{% assign array_size = acc_titles.size | minus: 1 %}
{%- for i in (0..array_size) -%}
{% assign title_value = acc_titles[i] %}
{% assign icon_value = acc_icons[i] | downcase | replace: " ", "-" | replace: "_", "-" | replace: ".", "-" %}
{% assign page_value = acc_pages[i] %}
{% assign rich_value = acc_rich_texts[i] %}
{%- if rich_value != blank or page_value.content != blank -%}
{%- capture item_content -%}
<div class="prose">
{%- if page_value.content != blank -%}
{{ page_value.content }}
{%- else -%}
{{ rich_value | metafield_tag }}
{%- endif -%}
</div>
{%- endcapture -%}
{%- render 'accordion-dynamic', icon: icon_value, title: title_value, content: item_content, class: 'product-info__accordion', block: block -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
Thank you,