Skip Navigation

[Resolved] Nested search results to match parent criteria and prevent repeating search box

This support ticket is created 7 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 7 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#487240
searchChildren.png
repeating search (1).png

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.

#487371

Hi,

Q1) inserted with view_display="layout" within the view shortcode. But still the searchbox repeats down the page.
This is abnormal, I can not duplicate same problem, please check these:
1) make sure you are follow our document to setup the view's shortcode:
https://toolset.com/documentation/user-guides/front-page-filters/#displaying-custom-search
2) deactivate other plugins and switch to wordpress default theme, and test again

Q2) Could you describe more details for the questions?
How do you setup the nested views?
In your case, I suggest you create only one view, in section "Content Selection", enable all three post types: grandparent CPT, parent CPT and child CPT, and here is a document about "Filtering Views for a specific text string – search":
https://toolset.com/documentation/user-guides/filtering-views-for-a-specific-text-string-search/

Hope it help

#488779

Thanks, I will refer to the parametric search docs again.

However, it is a particular search outcome I am seeking here, with nested results. So I want the grandparent fields to be returned, with a link to reveal their children - but only those which match the string criteria in the search box.

The repeating search box issue must surely be a consequence of having a nested view within a view, no? - did you try that in your tests? I thought I might be able to work around it by setting display:none but I can't find an ID or a class to set it to. Might you shed any light on that?

Thanks again
Tim

#488793

I have double tested it in my localhost with the nested view, it works fine, the shortcode [wpv-view name="xxxx" view_display="layout"] can only display the search results, without the search form.

Are you using the latest version of Views plugin?
Have you tried to deactivate plugins and switch to default theme?

If the problem still exists, please provide a test site with same problem, I need to test and debug it in a live website, thanks

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.