Hallo,
With the help of the plugin info about the contacts collection in the flex-objects description I created an own collection about Records.
Everything works fine except the search in the collection. The search is only on the name (naam) not the title (titel) or the box (doos).
My search criteria in the records.yaml file looks like:
search:
# Search options
options:
contains: 1
# Fields to be searched
fields:
- naam
- titel
- doos
I used the Collection template flex/contacts/collection/default.html.twig
. The last lines I changed to:
<script>
var options = {
valueNames: [ 'naam','titel','doos']
};
var flexList = new List('flex-objects',options);
</script>
What I experienced:
-
I can only search on name not title or box;
-
The flex/contacts/collection/default.html.twig of the contacts example has two lines added at the beginning of the file. When I add those two lines in my twig file the collection doens’t show a thing.
The two lines which are added are:{%- set object_context = object ?? {} -%}
{%- set object_layout = object_context.layout ?? (‘list-’ ~ layout) -%}
My questions are:
- Have I executed the right steps?
- What should I do to be able to search on all the three items (naam, titel, doos)?
- Why gives the search no results when the two lines are added?
- Is there a general recipe to make collections using flex-objects or should you follow the example steps of contacts in de plugin description?
With the limited knowledge of twig I am not able to solve this.
Thanks for giving me the answers.
By the way flex-object is a great extension to grav.