TransWikia.com

List out all "Layout Tabs" in the frontend

Craft CMS Asked by Mark Notton on April 7, 2021

enter image description here

I have a few tabs in my “Field Layout Design”, and I wondered if there was a way to list the titles of each one, in the frontend? Something basic like:

<ul>
  <li>Services</li>
  <li>Testimonials</li>
  <li>Gallery</li>
</ul>

Thanks 🙂

One Answer

Assuming you have an 'entry', this should work:

{% for tab in entry.getFieldLayout().getTabs() %}
    <ul>
        <li>{{ tab.name }}
            <ul>
                {% for field in tab.getFields() %}
                    <li>{{ field.name }}</li>
                {% endfor %}
            </ul>
        </li>
    </ul>
{% endfor %}

if you don't need the fields then just:

{% for tab in entry.getFieldLayout.getTabs() %}
    <ul>
        <li>{{ tab.name }}</li>
    </ul>
{% endfor %}

Correct answer by Douglas McDonald on April 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP