From 9dfaf013bb0b6b9c7a7f791ecdf8ee950265efeb Mon Sep 17 00:00:00 2001 From: Sascha Vogl Date: Fri, 25 Oct 2024 09:30:37 +0200 Subject: [PATCH 1/4] remove unset(id), hide on detail --- plugin/AddressList.php | 1 - templates.dist/address/default_detail.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/plugin/AddressList.php b/plugin/AddressList.php index 846dae914..39fd5c0e3 100644 --- a/plugin/AddressList.php +++ b/plugin/AddressList.php @@ -269,7 +269,6 @@ private function fillAddressesById(array $records) $elements = $address['elements']; $additionalContactData = $this->collectAdditionalContactData($elements); - unset($elements['id']); $this->_addressesById[$address['id']] = array_merge($elements, $additionalContactData); } } diff --git a/templates.dist/address/default_detail.php b/templates.dist/address/default_detail.php index 79f143906..a84a78004 100644 --- a/templates.dist/address/default_detail.php +++ b/templates.dist/address/default_detail.php @@ -52,7 +52,7 @@
$value) { - if (in_array($field, $addressName) || empty($value)) { + if (in_array($field, $addressName) || empty($value) || $field == 'id') { continue; } echo '
'; From 7731f865dde9138c12ecdd27abb9f134b58cb87b Mon Sep 17 00:00:00 2001 From: Sascha Vogl Date: Fri, 25 Oct 2024 09:30:57 +0200 Subject: [PATCH 2/4] add Function to get Addresslink --- plugin/EstateDetail.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugin/EstateDetail.php b/plugin/EstateDetail.php index 0e4aea8be..283789600 100644 --- a/plugin/EstateDetail.php +++ b/plugin/EstateDetail.php @@ -320,5 +320,14 @@ public function getShowEstateMarketingStatus(): bool { return $this->getDataView()->getShowStatus(); } - + /** + * Returns addresslink for given addressid + * @param string $id + * @return string + */ + public function getAddressLink(string $id) : string + { + $link = $this->getEnvironment()->getAddressList()->getAddressLink($id); + return $link; + } } From e686684860ad5d0b2fa9b24be3af16fe3c08657e Mon Sep 17 00:00:00 2001 From: Sascha Vogl Date: Fri, 25 Oct 2024 09:45:55 +0200 Subject: [PATCH 3/4] fix test --- tests/TestClassAddressList.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/TestClassAddressList.php b/tests/TestClassAddressList.php index 1684cf1ae..41aae6d71 100644 --- a/tests/TestClassAddressList.php +++ b/tests/TestClassAddressList.php @@ -73,11 +73,13 @@ class TestClassAddressList '01234567890', '01122334455', ], + 'id' => 13 ), 37 => array( 'Name' => 'Fleißig', 'KdNr' => 12, 'Vorname' => 'Heinrich', + 'id' => 37 ), ]; From 2bc22cddc7ccdca28598ed47dee767fa0728041a Mon Sep 17 00:00:00 2001 From: Sascha Vogl Date: Tue, 29 Oct 2024 11:03:03 +0100 Subject: [PATCH 4/4] add return empty string when no id found --- plugin/AddressList.php | 4 +++- plugin/EstateDetail.php | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plugin/AddressList.php b/plugin/AddressList.php index 39fd5c0e3..9c0dd9bee 100644 --- a/plugin/AddressList.php +++ b/plugin/AddressList.php @@ -571,7 +571,9 @@ public function getAddressLink(string $addressId): string { $pageId = $this->_pEnvironment->getDataAddressDetailViewHandler() ->getAddressDetailView()->getPageId(); - + if($pageId == 0) { + return ""; + } $url = get_page_link( $pageId ) . $addressId; $fullLinkElements = parse_url( $url ); if ( empty( $fullLinkElements['query'] ) ) { diff --git a/plugin/EstateDetail.php b/plugin/EstateDetail.php index 283789600..1030457a0 100644 --- a/plugin/EstateDetail.php +++ b/plugin/EstateDetail.php @@ -327,7 +327,6 @@ public function getShowEstateMarketingStatus(): bool */ public function getAddressLink(string $id) : string { - $link = $this->getEnvironment()->getAddressList()->getAddressLink($id); - return $link; + return $this->getEnvironment()->getAddressList()->getAddressLink($id); } }