1

wonder if a guru could help, I am nearly there, just stuck on the right call.

Building a standard css/jquery responsive tab solution. I am pulling back child entries to populate a parent page with said tabs. The problem is the for loop, not being able to close the unordered list before the next part. I wonder if anyone could help please.

    <!-- Tabs -->
{% set entries = craft.entries.section('country').level(3) %}
<ul class="tabs">

{% for entry in entries %}
<li {% if loop.first %} class="" {% else %} class="active" {% endif %} rel="{{ loop.index }}">{{entry.pageTitle}}</li>

</ul>

<div class="tab_container">

<!-- start tab -->
<h3 {% if loop.first %} class="d_active tab_drawer_heading"  {% else %} class="tab_drawer_heading" {% endif %}  rel="{{ loop.index }}">{{entry.pageTitle}}</h3>
<div id="{{ loop.index }}" class="tab_content">
{{entry.pageTitle}}
</div>
<!-- end tab -->
{% endfor %}
</div><!-- .tab_container -->
1

I would go for two loops to make it easier to maintain sanity later on:

<!-- Tabs -->
{% set entries = craft.entries.section('country').level(3) %}
<ul class="tabs">
   {% for entry in entries %}   
   <li class="{% if loop.first %}active{% endif %}" rel="{{ loop.index }}">{{entry.pageTitle}}</li>
   {% endif %}
</ul>


<!-- Tab_container -->
<div class="tab_container">
   {% for entry in entries %}  
   <h3 class="{% if loop.first %}d_active{% endif %} tab_drawer_heading" rel="{{ loop.index }}">{{entry.pageTitle}}</h3>
   <div id="{{ loop.index }}" class="tab_content">
      {{entry.pageTitle}}
   </div>
   {% endfor %}
</div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.