Hopefully I’m asking this in the right place! I’ve been poking at template pages on local, trying to create a ‘listing’ style page that will embed child pages within the same folder into it. This might be better accomplished with a modular page, but when I tried that things went all sideways and looked worse than what I already had, so I panicked and retreated.
What I’m trying to do is place each child page into its own nav tab, so that whenever I add a new child page folder a new tab will appear automatically. I’m essentially going for something like this:
This way readers can decide which format works best for them and their accessibility needs in a way that feels seamless. I’ve been trying to accomplish this by hitting the Bootstrap4 theme with a hammer, and I feel like I’ve almost got it, but I can’t quite figure out what variables I should be using to actually make it work. I’ve been trying to use isFirst(), but… I don’t know if that actually works with child pages. And I’m also not very good at coding, in general.
What I’ve got in my template is this:
<ul class="nav nav-tabs" id="myTab" role="tablist">
{% for child in collection %}
<li class="nav-item">
<a class="nav-link active" id="text-tab" data-toggle="tab" href="#{{ child.title }}" role="tab" aria-controls="{{ child.title }}" aria-selected="{{ isFirst(current.child) ? 'true':'false' }}">{{ child.title }}</a>
</li>
{% endfor %}
</ul>
<div class="tab-content" id="myTabContent">
{% for child in collection %}
<div class="tab-pane fade show active" id="{{ child.title }}" role="tabpanel" aria-labelledby="{{ child.title }}-tab">
<br />
{% include 'partials/blorf.html.twig' with {'page': child} %}
</div>
{% endfor %}
</div>
The result of which isn’t actually functional. Neither tab is selected or selectable, and the contents of both children appear one right after the other underneath them instead of being contained within the tabs.
Is there an easy variable change I can make to get this working? Or should I be mangling another theme entirely?