Skip to content

Instantly share code, notes, and snippets.

@DonKoko
Created March 17, 2017 15:02
Show Gist options
  • Save DonKoko/1fd68878acfc1f45d464456c65797acb to your computer and use it in GitHub Desktop.
Save DonKoko/1fd68878acfc1f45d464456c65797acb to your computer and use it in GitHub Desktop.
filtering
{% action "Filter gemeente entries" %}
// Get the current municipality(scope of the page)
var municipality = getProp("municipality");
// Get the name of the current category for the breadcrumbs
var category_query = getProp('params.category_query');
setProp('category_query', category_query);
// Find all locations within that municipality
var locations = allEntries('locations', {'municipality': municipality});
var locations_ids = []; //Initiate empty array
// Add the ids of all locations within current gemeente
for (var i = 0; i < locations.length; i++) {
locations_ids.push(locations[i]._id)
}
// find all locations without gemeente
var locations_without_gemeente = allEntries('locations', {"municipality_id": null });
// Add the ids of all locations without gemeente
for (var i = 0; i < locations_without_gemeente.length; i++) {
locations_ids.push(locations_without_gemeente[i]._id)
}
setProp("locations_ids", locations_ids);
{% endaction %}
{% with_scope categories: params.category_query, locations.in: locations_ids %}
{% include 'main_section' %}
{% endwith_scope %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment