Site-wide search including events from Solspace Calendar? (Low Search)
I have a simple keyword search that's available at the top of every page.
It contains 1 input field.
{exp:low_search:form
required = "keywords"
result_page = "search/results"
form_class = "search"
}
Search keywords
Search
{/exp:low_search:form}
I've also installed Low Search Calendar extension.
https://github.com/low/low_search_cal...
I have 5 collections and without 'calendar:method' the below results tag pair outputs results from all collections as expected, including the 'Events' collection. But specific Calendar tags are not available without the custom extension. Adding 'calendar:method = "events"' gets the 'event_first_date' tag to render but then only results form 'Events' collection show and no other entries.
{exp:low_search:results
query = "{segment_3}"
limit = "5"
require_query = "yes"
paginate = "both"
keywords:lang = "en"
keywords:inflect = "yes"
calendar:method = "events"
}
{title}
{event_first_date format="%j %F %Y at %g:%i%a"}
How can I have results from all collections AND specific tags for Calendar?
Replies
Low 18 Mar 2015 18:26
Ah, yes, there's the rub.
Technically, the Low Search Calendar (LSC) add-on isn't a filter, but an extension.
To clarify, Low Search calls the channel:entries tag to display search results. When LSC is installed and you use calendar:method="events", LS will call calendar:events instead. This was the only way to be able to dynamically filter Solspace Calendar events by their parameters.
Now, knowing that, you'll see that it is not possible to display events and regular entries in one stream.
I'll make a note of that in the LSC docs.
Elliot 18 Mar 2015 18:39
Ah nuts. That makes sense, I've not looked in to the internal workings of Calendar but makes sense for it to use it's own tables in addition to channel_title / channel_data.
Low Search does return keyword results and as I'm not filtering calendar events in any other way I might be able to display those fields using '{exp:calendar:events}'.
Thanks for the quick reply.
Low 19 Mar 2015 09:08
Solspace Calendar events are regular entries. However, the occurrences and filtering by date happens through a different table and Calendar's logic. You might be able to include events in your search results, but you won't be able to filter out those events by their dates.
Elliot 19 Mar 2015 12:10
Yeah, for this use case, just a keyword search I've got it working. Just having events appear in the listing based on the title is good. They can filter by day/month etc in the events area.
FYI to anyone reading this I tried using {exp:calendar:events} to retrieve the times but this doubled the number of SQL queries when showing 5 results per page! Went from 55 to 111.
I used the Query module to pull out just the times, 5 extra queries.