Skip to content

Commit

Permalink
Merge pull request #39 from helsingborg-stad/fix/osm-filtering
Browse files Browse the repository at this point in the history
fix: osm filtering
  • Loading branch information
NiclasNorin authored Jun 19, 2024
2 parents 1d43a12 + 700e756 commit 5b32ee9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
4 changes: 2 additions & 2 deletions source/php/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public function postTypes($field)
$postTypes = get_post_types();
$arr = [];
foreach ($postTypes as $postType) {
$schemaType = get_field('schema', $postType . '_options');
if ($schemaType === 'Place') {
$contentType = \Municipio\Helper\ContentType::getContentType($postType);
if (is_object($contentType) && $contentType->getKey() == 'place') {
$postTypeObject = get_post_type_object($postType);
$arr[$postTypeObject->name] = $postTypeObject->label;
}
Expand Down
21 changes: 9 additions & 12 deletions source/php/Module/OpenStreetMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,18 @@ public function replaceArchivePosts($item)
public function data(): array
{
$fields = get_fields($this->ID);
$secondaryQuery = get_query_var('secondaryQuery');
$data['ID'] = !empty($this->ID) ? $this->ID : uniqid();

if (empty($secondaryQuery)) {
$termsToShow = $fields['mod_osm_terms_to_show'];
$postTypeToShow = $fields['mod_osm_post_type'];
$taxonomyToShow = [];
foreach ($termsToShow as $term) {
$taxonomy = get_term($term)->taxonomy;
$taxonomyToShow[$taxonomy][] = $term;
}
$places = $this->getPlacePosts($termsToShow, $taxonomyToShow, $postTypeToShow);
} else {
$places = $secondaryQuery->posts;
$termsToShow = $fields['mod_osm_terms_to_show'];
$postTypeToShow = $fields['mod_osm_post_type'];
$taxonomyToShow = [];

foreach ($termsToShow as $term) {
$taxonomy = get_term($term)->taxonomy;
$taxonomyToShow[$taxonomy][] = $term;
}
$places = $this->getPlacePosts($termsToShow, $taxonomyToShow, $postTypeToShow);

$data['isFullWidth'] = $fields['mod_osm_full_width'] ?? false;
$data['places'] = $places;
$data['mapStyle'] = $this->getMapStyle();
Expand Down
2 changes: 1 addition & 1 deletion source/php/Module/views/partials/collection.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'containerAware' => true,
'bordered' => true,
'attributeList' => [
'data-js-map-location' => !empty($place->openStreetMapData['pin']) ? json_encode($place->openStreetMapData['pin']) : "",
'data-js-map-location' => !empty($place->schemaData['place']['pin']) ? json_encode($place->schemaData['place']['pin']) : "",
]
])
@if (!empty($place->callToActionItems['floating']))
Expand Down

0 comments on commit 5b32ee9

Please sign in to comment.