Hi there,
My question is the same as https://toolset.com/forums/topic/is-conditional-output-in-accordion-possible/.
I wasn't able to answer my question from that ticket, because not all the steps were documented.
I have a Bootstrap accordion showing various views.
I want to conditionally hide the panel if the view within it is empty.
Here is the view with the panels: hidden link
For example:
<button class="accordion">Step-by-Step Photo Instructions: [wpv-post-title]</button>
<div class="panel">
<h4>Step-by-Step Photo Instructions: [wpv-post-title]</h4>
<p>[wpv-view name="step-photos-for-bind-offs-class"]</p>
</div>
If the view "step photos for bind-offs class" doesn't return any results, I don't want to show the panel or its button.
Can you show me how to conditionally hide the button if the view is empty?
Here is the view contained in the panel: hidden link
Thank you,
Liat
Dear Liat,
I can get your website credentials in your previous thread:
https://toolset.com/forums/topic/help-creating-a-nested-view-of-taxonomy-terms-to-display-on-archive-page-sidebar/#post-1101839
Yes, it is possible. you just need to move those panel HTML codes into the child view, within shortcode [wpv-items-found] ... [/wpv-items-found], for example:
Edit the view "Panels for BIND-OFFS CLASS"
hidden link
in section "Loop item in Chapter View with anchor and Panels for BIND-OFFS CLASS", change the codes from:
<button class="accordion">Step-by-Step Photo Instructions: [wpv-post-title]</button>
<div class="panel">
<h4>Step-by-Step Photo Instructions: [wpv-post-title]</h4>
<p>[wpv-view name="step-photos-for-bind-offs-class" knitting_videos_id="[wpv-post-id]"]</p>
</div>
To:
[wpv-view name="step-photos-for-bind-offs-class" knitting_videos_id="[wpv-post-id]"]
Pass knitting_videos post ID as view's shortcode attribute "knitting_videos_id"
2) Edit the child view "Step Photos for Bind-Offs Class", in section "Loop Editor", change the code as below:
...
[wpv-items-found]
<div class="panel">
<h4>Step-by-Step Photo Instructions: [wpv-post-title id='[wpv-attribute name="knitting_videos_id"]']</h4>
<p>
...
</p>
</div>
[/wpv-items-found]
...
More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-attribute
My issue is resolved now. Thank you!