diff --git a/packages/ep_products/Classes/Controller/ProductController.php b/packages/ep_products/Classes/Controller/ProductController.php index 72bb831..4aaa102 100644 --- a/packages/ep_products/Classes/Controller/ProductController.php +++ b/packages/ep_products/Classes/Controller/ProductController.php @@ -91,10 +91,6 @@ class ProductController extends ActionController $isProductWithGroupInquiryForm = ($concept !== null) && \in_array($concept->getUid(), $groupInquiryFormConceptUids); $nonBookableInfo = $product->getNonBookableInfo(); - // Assemble backlink - $backlinkUrl = $this->request->getQueryParams()['ref'] ?? null; - $backLinkLabel = strpos((string)$backlinkUrl, 'suche') !== -1 ? 'zurück zum Suchergebnis' : 'zurück'; - $this->view->assignMultiple([ 'hotel' => $hotel, 'product' => $product, @@ -106,8 +102,6 @@ class ProductController extends ActionController 'currentPageUid' => $this->request->getAttribute('frontend.page.information')->getId(), 'dateFrom' => $dateFrom, 'dateTo' => $dateTo, - 'referringUrl' => $backlinkUrl, - 'backlinkLabel' => $backLinkLabel, 'nonBookableInfo' => $nonBookableInfo, 'pickupsOverview' => $this->pickupOverviewService->getOverview($product, $hotel), ]); diff --git a/packages/ep_theme/Resources/Private/Assets/js/controllers/backlink_controller.js b/packages/ep_theme/Resources/Private/Assets/js/controllers/backlink_controller.js new file mode 100644 index 0000000..3e1d99d --- /dev/null +++ b/packages/ep_theme/Resources/Private/Assets/js/controllers/backlink_controller.js @@ -0,0 +1,25 @@ +import { Controller } from '@hotwired/stimulus' + +// The page is cached alike for every visitor, so the link back to the visitor's own search is +// taken from ?ref= here, and only when it points to this site: anything else, javascript: URLs +// included, has a different origin +export default class extends Controller { + + connect() { + const ref = new URLSearchParams(window.location.search).get('ref') + if (null === ref) { + return + } + let url + try { + url = new URL(ref, window.location.href) + } catch { + return + } + if (url.origin !== window.location.origin) { + return + } + this.element.href = url.href + this.element.classList.remove('hidden') + } +} diff --git a/packages/ep_theme/Resources/Private/Partials/Product/HeaderDetail.html b/packages/ep_theme/Resources/Private/Partials/Product/HeaderDetail.html index fcb7913..9053d2b 100644 --- a/packages/ep_theme/Resources/Private/Partials/Product/HeaderDetail.html +++ b/packages/ep_theme/Resources/Private/Partials/Product/HeaderDetail.html @@ -55,12 +55,10 @@ - - - {ep:icon(icon: 'chevron-left', class: 'w-4 h-4 text-white')} - {backlinkLabel} - - +