How do you get 'Did You Mean' and 'Search Information' blocks to appear?
3 years, 8 months ago #13500
Hi. I’m looking through the .twig templates and I can see did-you-mean.twig and information.twig being included in the Ajax search. I was wondering how I include these templates on my search.php results page?
Many thankswpsolrKeymaster3 years, 8 months ago #13501
These informations are only available to the Ajax search templates, when the Ajax mode is flagged on in 2.1
Right now, there is no way to get them in your search.php.
You can ask for that feature in https://www.wpsolr.com/forums/forum/technical-configuration-issues/new-features-requests/3 years, 8 months ago #13502
Thanks. Sorry for the confusion, but the plugin indicates that the Ajax search templates are deprecated:
Is that not the case?wpsolrKeymaster3 years, 8 months ago #13503
I agree, it is confusing.
1) Historically, the Ajax search template (no “s”) came first. It was a monolithic shortcode added to a page created by the plugin. Built with a long string of code, no customizations possible.
2) Then came the “Use your own theme” option in 2.1 for archive pages, which intercepts the global $wp_query, but let the archive manipulate the results to display the UI as usual. With 2 exceptions: the WPSOLR widgets (facets, and sort) that can be inserted in the archive pages.
3) The 2 widgets and the Ajax template shared the same code to display facets and sorts. This was the first refactoring of code.
4) Then recently the Twig templates. Both the Ajax search template, and the 2 widgets, now receive data and pass it to their own twig files.
So, the code has been cleaned quite a lot. But the Ajax search template is still monolithic: it is still made of other templates in a fixed manner. The results twig template, pagination twig template, did you mean twig template still leave inside the Ajax search twig template. They cannot be recombined at will, nor can be used as widgets, nor can be used standalone.
Views are the next step, not planned yet. As for Toolset views, the idea would be to build custom views from several twig templates, customize their Elasticsearch/Solr query, and paste them anywhere. This is probably your goal, as I understand.
Once we have views, then we can build almost anything. For instance Elementor widgets: drag&drop facets, results, pagination in a page, associated to a custom query.
I hope this is a bit clearer now.3 years, 8 months ago #13504
Thanks for the detailed response. Yes, that is clearer.
You must be logged in to reply to this topic.