-
-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search within contenttype #1578
Comments
This is something that can be done in twig only, on the frontend.. Do you think this is something that should be coe functionality, or a snippet or something elsewhere explaining how to do it? |
Hmm, I think that depends on how easy it is to implement in twig. If it is several lines of straightforward code, I think snippet / docs how-to page is better... less noise in core. If not, putting it in core (or extension?) is needed imho. It looks like a fairly common use case to be able to search for blog posts, news, events, etc. and be able to display them with the same listing template (rather than the generic search one). Let's see if we can look it up tomorrow :-) |
okay, we have a bolt.tips entry about that, using:
Documentation needs updating, do we even need |
i have just implemented this in my project with a slight change to the listingController and contentRepository ( both of which are in my project/src - not vendor/bolt/src). All params are passed and if search (anyfield) is given it performs a searchNaive() on the search term in all fields and taxonomies and returns records to the listing.twig. It also allows specific fields and taxonomies to be queried in the url (using the changes in selectQuery.php i've just PR #1541 ) and returns results to the listing. functions including changes below: listingController.php
contentRepository.php
I don't seem to be too successfull with PRs but can try to pr these if you think they may help like? |
as an aside, i just have a simple search form on the listing page /taxa which submits to itself eg /taxa?search=xxxxx
|
@JTNMW you can also take a look at this: pretty simple :-) |
@I-Valchev, ok, that's great, thanks. That would seem to mitigate me having to use custom listingController.php and contentRepository.php. I think i changed these as i wanted the search (anyField) to be able to search in taxonomies as well as fields, but ive since added this ability to selectQuery.php (see pr #1541) which i gather is used by setcontent anyway. would this method work with multiple (and unknown) query parameters on submission of a form with many options? what would be the best way to get all app.request params and loop through adding to the where {}. ?? for example, if i have the the url /taxa?genera=abana&continent=Nearctic after submitting a form on the listing page (where genera is a taxonony slug, and continent is a field) could the twig end up bing created dynamically like this? {% setcontent records = contenttype.slug where { 'genera': 'abana', 'continent': 'nearctic' } %} |
@JTNMW Here's some pointers: And then you'd pass that object after the where, like so: |
If I am on a listing page, e.g.
/blog
I want to be able to add a search form that, on submit, goes to/blog?search=term
.On that listing page with query param
search
, I want therecords
variable to only include records matched against the search term.Afaik, this is not (yet) implemented, right? @bobdenotter
The text was updated successfully, but these errors were encountered: