Home › Toolset Professional Support › [Resolved] views text search box returns Relevanssi search results on a separate page
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.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | - |
- | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | - |
Supporter timezone: Europe/London (GMT+00:00)
Tagged: Views, Views plugin
This topic contains 14 replies, has 2 voices.
Last updated by davidm-13 6 years, 2 months ago.
Assisted by: Nigel.
Tell us what you are trying to do?
I have a view:
[wpv-filter-start hide="false"] [wpv-filter-controls] <div class="form-group"> [wpv-filter-search-box placeholder="Enter medical complaint (eg. rheumatism), system (eg. respiratory), action (eg. diuretic)" output="bootstrap"] </div> [/wpv-filter-controls] [wpv-filter-end]
The Query Filter is:
Filter post title, content and fields by a text search that will be added manually using the shortcode [wpv-filter-search-box].
Not sure what I need to put in the Loop Editor and Output Editor.
I've indexed my custom fields and taxonomies using Relevanssi (free) plugin .
I want to enter search terms into the Views search box and receive the output from Relevanssi on a separate page (view).
Really appreciate any help on how to achieve this.
Is there any documentation that you are following?
https://toolset.com/documentation/user-guides/searching-texts-custom-fields-views-relevanssi/
What is the link to your site?
hidden link - the text search box is "Search Ethnobotanical Uses"
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi David
You should build the View as if it were a normal View where the search form and results are shown together on the same page.
So the Loop Editor should presumably output the post titles as links at a minimum.
The Output Editor you normally don't need to touch, it contains two shortcodes, one which inserts the search form and another which inserts the search results, but you would only need to make any changes here (generally) if you wanted to add some additional markup, to split these into columns, for example.
The part where you split the search form and results happens when you use the Fields and Views button to insert the View.
Start on the page that will have the search form and insert the View. At the first step specify that you want the search form only, and that the results will be on a different page. It will then direct you to copy and paste a shortcode onto the target page where you want the results to appear.
Hi Nigel, I'm still having problems with this.
The search form (view) is on the home page. I want to display the search results in a table.
In the loop editor I have:
[wpv-layout-start] [wpv-items-found] <!-- wpv-loop-start --> <table width="100%"> <tr> <th>Botanical name</th> <th>English names</th> <th>Arabic names</th> <th>Hebrew names</th> </tr> <tbody class="wpv-loop js-wpv-loop"> <wpv-loop> <tr> [wpv-post-body view_template="Loop item in ethnobotanical search"] </tr> </wpv-loop> </tbody> </table> <!-- wpv-loop-end --> [/wpv-items-found] [wpv-no-items-found] <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong> [/wpv-no-items-found] [wpv-layout-end]
When you say "Start on the page that will have the search form and insert the View. " I assume we're talking about the front page above. In which section do I use the Fields and Views button to insert the view?
When you say " At the first step specify that you want the search form only, and that the results will be on a different page."
Could you be more specific (maybe there's an example you can point me to) about how and where I specify this?
Thanks
David
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi David
Sorry for the confusion, I don't mean making any edits to the View itself, I'm literally talking about when you insert the View.
So in the screenshot you can see I am inserting a View onto a page, and I have chosen to insert only the search form, and specified that I will insert the results on a separate page. Clicking the blue button will open up the target page editor in a new tab with instructions on how to insert the results.
Hi Nigel, really appreciate you taking the time to help.
Not sure what I'm doing wrong, but I don't seem to be able to get to the "Filtered things" you show in the screenshot.
I'm trying to set up a custom search, but the filter section in the screenshot is not the same as yours and the custom search setting does not include "What do you want to display in this cell"
Thanks
David
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi David
In those screenshots you are editing the View.
This is not about editing the View.
This is about inserting the View onto a page.
Now that you have created a View you need to display it somewhere, and in your case you want to display part of it on one page (the search box) and part of it on another page (the results).
So, edit the page where you want to insert the View search box.
Use the Fields and Views button to insert the View (they appear last, after all the fields).
Then you will see the dialog I showed in my last reply, from where you can choose whether to insert the entire View (filters and results) or just the filters.
Thanks for showing me the error of my ways, I think we're now both on the same page.
First I have a question about using Relevanssi, if I've built the index, do I also need to specify the query filters that where in the index in the View?
I setup a results page and used the Field & Views button on the page that contains the search form and on the results page, but all I received on the results page was the table header without any without any results.
Thanks
David
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi David
Relevanssi shouldn't make much practical difference here.
Assume you are not using Relevanssi.
You have a View which includes several filter controls (e.g. it has a status taxonomy filter) as well as a text search filter.
You insert that View across two pages, the first with the filter controls, the second with the results.
When you visit the first page and choose some filter controls (e.g. you select a taxonomy term from a dropdown and also enter a text search term "secondary") then hit submit, the View will query the database for posts of the specified type which have the taxonomy term assigned and which have the word "secondary" in the post title or post content.
If you repeat this with Relevanssi activated, the same happens, but the Relevanssi index is used for the text search, and that index will likely also include values stored in custom fields (depending on your Relevanssi settings).
To eliminate any confusion arising from splitting the View, on a test page insert the complete View. Try searching.
If no results are returned it is because no results match your search.
Hi Nigel, Thanks for the explanation.
I think I omitted an important point, I'm searching taxonomies and custom fields in - complaints - the child posts, and want the results to display fields from - plants - the parent posts.
Sorry only just realized that this is probably why I'm not seeing any results. How would I incorporate this into the current setup.
Thanks
David
Hi Nigel,
Been trying to work this out, problem is the results are blank - see screenshot search-results1.
I also understand it's only searching the title - I have taxonomies and custom fields in the Complaints posts which I need to include in the search. If any terms entered in the search box appear anywhere in the Complaints Post including its taxonomies and custom fields then I want the parent details to appear in the results - see screenshots - what am I doing wrong?
Thanks for your help
David
I also tried
<tr> <td>[wpv-post-title id="$plant" output="raw"]</td> <td>[wpv-post-taxonomy type="english-name" id="$plant" format="name"]</td> <td>[wpv-post-taxonomy type="arabic-name" id="$plant" format="name"]</td> <td>[wpv-post-taxonomy type="hebrew-name" id="$plant" format="name"]</td> </tr>
This results in the screenshot -search-results2.jpg- where the wpv-post-title is the child post title and not the parent post title - seems that id="$plant" is being ignored which would explain why the rest of the columns are blank.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi David
id="$parent" is from Types 2, and won't work with relationships in Types 3.
First, make sure the Content Selection of your search View is the child complaints posts. Those are the posts you want to search, so that is what your View must be querying.
To search taxonomies and custom fields of complaint posts make sure you have that set up in your Relevanssi indexing (normal text search will only search the title and content, and without Relevanssi you would need to add normal filters for taxonomies and custom fields). You can, of course, only search for complaint posts by taxonomy or custom field if those taxonomies and custom fields actually belong to the complaint post.
So, this View should return complaint posts that match the search criteria.
In the output section you want to output fields of the parent plant posts.
With Types 3 you now use the item shortcode attribute, rather than id.
The best way to generate the correct shortcode with attribute it to insert the required fields using the Fields and Views button, and then in the modal dialog choose the Post selection tab, where you can specify that the source post for this field should come from a related post.
Hi Nigel,
Thanks very much for this, everything is nearly working as I need.
I would like to sort the results by one of the taxonomies of the parent post that appears in the results, but when I put this in the "sort by" field I receive a "no results" message, do you have a solution for this?
Thanks
David
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi David
That's not possible currently.
Unless you start writing custom SQL queries, you can only filter by and order by properties of the thing being queried.
So if you are querying child posts, only properties of the child post (fields or taxonomies) can be used.
We are currently working on improving Views to enable this without resorting to custom code, so that you can use fields of related posts, but that is at least weeks, and maybe a couple of months away.
My issue is resolved now. Thank you!
Thanks for all your help, really appreciated.
I'll look at sorttable.js see if I can sort the results using that.
How will I know if/when this option is added to toolset views?
Thanks
David