I am trying to create a nested search results table for three post types.
In this scenario there is a grandparent CPT, parent CPT and child CPT. The solution needs to list the grandparents, with collapsed (expandable) rows of parents, which themselves have collapsed (expandable) rows of grandchildren. I am using bootstrap's collapse class to generate the nested results.
If no grandparent items are found then it should list matching parents, with nested collapsable children; and if no parents are found then the search should list only children which match the criteria.
I am theorising that I can do this by having a set of nested views planted in the loop, so that matching child posts are shown under their parents. I would then also have a nested view between the [wpv-no-items-found] shortcodes which will run for child posts only if its parents aren't found. Is my theory correct?
Following is the parent view with nested child:
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<table width="100%" class="table table-striped table-condensed table-responsive table-hover">
<thead><tr>
<th>[wpv-heading name="post-type"]Record Type [wpv-post-type][/wpv-heading]</th>
<th>[wpv-heading name="post-link"]Product Name [wpv-post-type][/wpv-heading]</th>
<th>[wpv-heading name="types-field-expectedspeciesreactivity"]Expected Species Reactivity[/wpv-heading]</th>
<th>[wpv-heading name="types-field-applicationcodesclone"]Applications[/wpv-heading]</th>
<!-- <th>[wpv-heading name="types-field-synonyms"]Other Names for Target[/wpv-heading]</th> -->
</tr></thead>
<tbody>
<wpv-loop>
<tr class="clickable" data-toggle="collapse" id="[wpv-post-id]" data-target=".[wpv-post-id]">
<td><i class="glyphicon glyphicon-plus"></i></td>
<td>[wpv-post-link]</td>
<td>[types field="expectedspeciesreactivity" output="raw" id=""][/types]</td>
<td>[types field="applicationcodesclone" output="raw" id=""][/types]</td>
</tr>
[wpv-view name="main-ababs-search-bootstrap" view_display="layout" wpvprchildof="[wpv-post-id]"]
</wpv-loop>
</tbody>
</table>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found][wpv-view name="main-ababs-search-bootstrap" view_display="layout" wpvprchildof="[wpv-post-id]"]
[/wpv-no-items-found]
[wpv-layout-end]
I have read the documentation on these pages:
https://toolset.com/documentation/user-guides/front-page-filters/#vfmh-displaying-just-your-filter
https://toolset.com/forums/topic/search-3/ - and subsequent docs.
I need help with two things please:
1. How to prevent the search box from repeating itself multiple times when the search is run: When entering a nested view I selected for it to show the results only, and it is inserted with view_display="layout" within the view shortcode. But still the searchbox repeats down the page.
2. How to specify, in a nested query, that the records returned should match the criteria entered in the parent's search box, as well as being children of the parent in the loop. I have added the filter saying:
"Filter post content and title by a text search that will be added manually using the shortcode [wpv-filter-search-box]"
... but it simply returns all children of the parent in the loop, instead of only those which match the search criteria. I can't find where to specify the search text.
Any help you can give with this will be much appreciated.
Many thanks.