Created
March 17, 2017 15:02
-
-
Save DonKoko/1fd68878acfc1f45d464456c65797acb to your computer and use it in GitHub Desktop.
filtering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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 %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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