Implement dynamic backlink, remove session storage

This commit is contained in:
Björn Fromme
2019-09-08 13:12:23 +02:00
parent ea2a777de7
commit e828aea169
10 changed files with 82 additions and 75 deletions
@@ -173,7 +173,6 @@ class ProductController extends ActionController
$this->view->assignMultiple([ $this->view->assignMultiple([
'hotels' => $hotels, 'hotels' => $hotels,
'product' => $product, 'product' => $product,
'currentPageUid' => $GLOBALS['TSFE']->id,
'linkHotel' => true, 'linkHotel' => true,
]); ]);
} }
@@ -30,8 +30,8 @@ import ContactForm from './components/ContactForm.vue'
import WatchlistToggle from './components/WatchlistToggle.vue' import WatchlistToggle from './components/WatchlistToggle.vue'
import Watchlist from './components/Watchlist.vue' import Watchlist from './components/Watchlist.vue'
import HotelList from './components/HotelList.vue' import HotelList from './components/HotelList.vue'
import ReferrerLink from './components/ReferrerLink.vue'
import FacebookPixel from './components/FacebookPixel.vue' import FacebookPixel from './components/FacebookPixel.vue'
import BackLink from './components/BackLink.vue'
// Define global constants // Define global constants
const $window = $(window); const $window = $(window);
@@ -64,7 +64,7 @@ new Vue({
WatchlistToggle, WatchlistToggle,
Watchlist, Watchlist,
HotelList, HotelList,
ReferrerLink, BackLink,
MyEp: () => import('./myep/components/App.vue'), MyEp: () => import('./myep/components/App.vue'),
FacebookPixel FacebookPixel
}, },
@@ -0,0 +1,31 @@
<template>
<div class="ep-backlink" v-if="referringUrl" v-cloak>
<a :href="referringUrl" class="button button--small">{{ label }}</a>
</div>
</template>
<script>
export default {
name: 'BackLink',
data () {
return {
referringUrl: null,
}
},
computed: {
label () {
if (this.referringUrl.match(/suche/)) {
return 'zurück zum Suchergebnis'
}
return 'zurück'
}
},
mounted () {
const urlParams = new URLSearchParams(location.search);
if (urlParams.has('ref')) {
this.referringUrl = urlParams.get('ref');
}
}
}
</script>
@@ -1,13 +1,11 @@
<script> <script>
import WatchlistToggle from './WatchlistToggle.vue' import WatchlistToggle from './WatchlistToggle.vue'
import ReferrerLink from './ReferrerLink.vue'
import defaultFilterSettings from '../_filtersettings' import defaultFilterSettings from '../_filtersettings'
export default { export default {
components: { components: {
WatchlistToggle, WatchlistToggle
ReferrerLink
}, },
props: { props: {
referringPageUrl: { referringPageUrl: {
@@ -14,6 +14,7 @@
import FacebookPixel from './FacebookPixel.vue' import FacebookPixel from './FacebookPixel.vue'
import WatchlistToggle from './WatchlistToggle.vue' import WatchlistToggle from './WatchlistToggle.vue'
import OsmMap from './OsmMap.vue' import OsmMap from './OsmMap.vue'
import BackLink from "./BackLink.vue";
import dayjs from 'dayjs' import dayjs from 'dayjs'
import 'dayjs/locale/de' import 'dayjs/locale/de'
@@ -29,7 +30,8 @@
Calendar, Calendar,
FacebookPixel, FacebookPixel,
WatchlistToggle, WatchlistToggle,
OsmMap OsmMap,
BackLink
}, },
data () { data () {
return { return {
@@ -1,28 +0,0 @@
<template>
<a @click="storeReferringPage()">
<slot></slot>
</a>
</template>
<script>
export default {
props: {
referringPage: {
type: Object,
default () {
return {
url: null,
label: null
}
}
}
},
methods: {
storeReferringPage () {
if (this.referringPage.url && this.referringPage.label) {
sessionStorage.setItem('referringPage', JSON.stringify(this.referringPage))
}
}
}
}
</script>
@@ -204,14 +204,11 @@
}, },
updateFilterSettings (settings) { updateFilterSettings (settings) {
this.filterSettings = { ...this.filterSettings, ...settings }; this.filterSettings = { ...this.filterSettings, ...settings };
sessionStorage.setItem('filterSettings', JSON.stringify(this.filterSettings));
} }
}, },
created () { created () {
if (!$.isEmptyObject(this.initialFilterSettings)) { if (!$.isEmptyObject(this.initialFilterSettings)) {
this.updateFilterSettings(this.initialFilterSettings) this.updateFilterSettings(this.initialFilterSettings)
} else if (sessionStorage.getItem('filterSettings')) {
this.updateFilterSettings(JSON.parse(sessionStorage.getItem('filterSettings')))
} }
}, },
mounted () { mounted () {
@@ -2,8 +2,7 @@
<div class="teaserbox teaserbox--landscape teaserbox--searchresult searchresult-item"> <div class="teaserbox teaserbox--landscape teaserbox--searchresult searchresult-item">
<div class="teaserbox__image"> <div class="teaserbox__image">
<img class="teaserbox__flag" :src="item.country.flag" :alt="item.country.name"/> <img class="teaserbox__flag" :src="item.country.flag" :alt="item.country.name"/>
<referrer-link :href="item.detailPageUri" :referring-page="referringPage" <a :href="getUrl()" rel="nofollow" title="Details &amp; Buchen">
rel="nofollow" title="Details &amp; Buchen">
<picture class="searchresult-item__image"> <picture class="searchresult-item__image">
<source media="(min-width: 1201px)" :data-srcset="item.hotel.images.resized.m[0].url + ' 260w'"/> <source media="(min-width: 1201px)" :data-srcset="item.hotel.images.resized.m[0].url + ' 260w'"/>
<source media="(max-width: 1200px)" :data-srcset="item.hotel.images.resized.l[0].url + ' 280w'"/> <source media="(max-width: 1200px)" :data-srcset="item.hotel.images.resized.l[0].url + ' 280w'"/>
@@ -12,7 +11,7 @@
:title="item.hotel.images.resized.s[0].title" :title="item.hotel.images.resized.s[0].title"
:alt="item.hotel.images.resized.s[0].alt"> :alt="item.hotel.images.resized.s[0].alt">
</picture> </picture>
</referrer-link> </a>
<div class="concept-badge" :id="section.concept.code" <div class="concept-badge" :id="section.concept.code"
:class=" 'concept-badge--' + section.concept.code">{{ section.concept.name }}</div> :class=" 'concept-badge--' + section.concept.code">{{ section.concept.name }}</div>
</div> </div>
@@ -45,21 +44,21 @@
<div class="teaserbox__aside__top"> <div class="teaserbox__aside__top">
<span class="searchresult-item__label">{{ item.dates.length > 1 ? 'Zeitraum' : 'Termin' }}</span> <span class="searchresult-item__label">{{ item.dates.length > 1 ? 'Zeitraum' : 'Termin' }}</span>
<span class="searchresult-item__daterange">{{ dateRange }}</span> <span class="searchresult-item__daterange">{{ dateRange }}</span>
<referrer-link :href="item.detailPageUri" :referring-page="referringPage" <a :href="getUrl()" rel="nofollow" title="Details &amp; Buchen"
rel="nofollow" title="Details &amp; Buchen" v-if="item.dates.length && !item.daytrip"> v-if="item.dates.length && !item.daytrip">
<span class="searchresult-item__daterange"> <span class="searchresult-item__daterange">
<i class="fa fa-arrow-circle-right"></i> {{ item.dates.length }} Termin{{ item.dates.length > 1 ? 'e' : '' }} <i class="fa fa-arrow-circle-right"></i> {{ item.dates.length }} Termin{{ item.dates.length > 1 ? 'e' : '' }}
</span> </span>
</referrer-link> </a>
<hr> <hr>
<span class="searchresult-item__label">{{ item.daytrip ? 'Tageweise buchbar' : nightsOptions }}</span> <span class="searchresult-item__label">{{ item.daytrip ? 'Tageweise buchbar' : nightsOptions }}</span>
</div> </div>
<div class="teaserbox__aside__bottom"> <div class="teaserbox__aside__bottom">
<span class="searchresult-item__price">ab {{ item.minPrice }} </span> <span class="searchresult-item__price">ab {{ item.minPrice }} </span>
<referrer-link :href="item.detailPageUri" :referring-page="referringPage" <a :href="getUrl()" class="button button--full searchresult-item__button"
class="button button--full searchresult-item__button" rel="nofollow" title="Details &amp; Buchen"> rel="nofollow" title="Details &amp; Buchen">
Details &amp; Buchen Details &amp; Buchen
</referrer-link> </a>
</div> </div>
</div> </div>
<watchlist-toggle :uid="item.key" class="teaserbox-watchlist"></watchlist-toggle> <watchlist-toggle :uid="item.key" class="teaserbox-watchlist"></watchlist-toggle>
@@ -70,12 +69,10 @@
import dayjs from 'dayjs' import dayjs from 'dayjs'
import 'dayjs/locale/de' import 'dayjs/locale/de'
import WatchlistToggle from './WatchlistToggle.vue' import WatchlistToggle from './WatchlistToggle.vue'
import ReferrerLink from './ReferrerLink.vue'
export default { export default {
components: { components: {
WatchlistToggle, WatchlistToggle
ReferrerLink
}, },
props: { props: {
item: { item: {
@@ -85,15 +82,11 @@
section: { section: {
type: Object, type: Object,
required: true required: true
}, }
referringPage: { },
type: Object, methods: {
default () { getUrl () {
return { return this.item.detailPageUri + '?ref=' + window.location.pathname;
url: null,
label: null
}
}
} }
}, },
computed: { computed: {
@@ -10,10 +10,13 @@
<img class="teaserbox__flag" <img class="teaserbox__flag"
src="{item.country.flag}" src="{item.country.flag}"
alt="{item.country.name}"/> alt="{item.country.name}"/>
<referrer-link href="{f:uri.action(pageUid: detailPage, action: 'detail', controller: 'Product', arguments: '{product: product.uid, hotel: item.hotel.uid}')}" <f:link.action action="detail" controller="Product"
:referring-page="{ url: referringPageUrl, label: 'zurück' }" rel="nofollow"> pageUid="{detailPage}"
arguments="{product: product.uid, hotel: item.hotel.uid}"
additionalParams="{ref: '{f:uri.page()}'}"
>
<f:render section="Image" arguments="{_all}"/> <f:render section="Image" arguments="{_all}"/>
</referrer-link> </f:link.action>
<f:if condition="{product.concept.code}"> <f:if condition="{product.concept.code}">
<div class="concept-badge concept-badge--{product.concept.code}">{product.concept.name}</div> <div class="concept-badge concept-badge--{product.concept.code}">{product.concept.name}</div>
</f:if> </f:if>
@@ -70,32 +73,46 @@
<span class="searchresult-item__label">{f:if(condition: '{item.dates -> f:count()} > 1', then: 'Zeitraum', else: 'Termin')}</span> <span class="searchresult-item__label">{f:if(condition: '{item.dates -> f:count()} > 1', then: 'Zeitraum', else: 'Termin')}</span>
<span class="searchresult-item__daterange">{ep:dateRange(dateFrom: item.minDateStart, dateTo: item.maxDateEnd, includeLabel: 0)}</span> <span class="searchresult-item__daterange">{ep:dateRange(dateFrom: item.minDateStart, dateTo: item.maxDateEnd, includeLabel: 0)}</span>
<f:if condition="{item.dates -> f:count()} > 1"> <f:if condition="{item.dates -> f:count()} > 1">
<referrer-link href="{f:uri.action(pageUid: detailPage, action: 'detail', controller: 'Product', arguments: '{product: product.uid, hotel: item.hotel.uid}')}" <f:link.action action="detail" controller="Product"
:referring-page="{ url: referringPageUrl, label: 'zurück' }" rel="nofollow"> pageUid="{detailPage}"
arguments="{product: product.uid, hotel: item.hotel.uid}"
additionalParams="{ref: '{f:uri.page()}'}"
additionalAttributes="{rel: 'nofollow'}"
>
<span class="searchresult-item__daterange"> <span class="searchresult-item__daterange">
<i class="fa fa-arrow-circle-right"></i> {item.dates -> f:count()} Termin{f:if(condition: '{item.dates -> f:count()} > 1', then: 'e')} <i class="fa fa-arrow-circle-right"></i> {item.dates -> f:count()} Termin{f:if(condition: '{item.dates -> f:count()} > 1', then: 'e')}
</span> </span>
</referrer-link> </f:link.action>
</f:if> </f:if>
<hr> <hr>
<span class="searchresult-item__label">{ep:nightsOptions(options: item.nights)}</span> <span class="searchresult-item__label">{ep:nightsOptions(options: item.nights)}</span>
</div> </div>
<div class="teaserbox__aside__bottom"> <div class="teaserbox__aside__bottom">
<span class="searchresult-item__price">ab {item.minPrice} €</span> <span class="searchresult-item__price">ab {item.minPrice} €</span>
<referrer-link href="{f:uri.action(pageUid: detailPage, action: 'detail', controller: 'Product', arguments: '{product: product.uid, hotel: item.hotel.uid}')}" <f:link.action action="detail" controller="Product"
:referring-page="{ url: referringPageUrl, label: 'zurück' }" pageUid="{detailPage}"
class="button button--full searchresult-item__button" rel="nofollow"> arguments="{product: product.uid, hotel: item.hotel.uid}"
additionalParams="{ref: '{f:uri.page()}'}"
additionalAttributes="{rel: 'nofollow'}"
class="button button--full searchresult-item__button"
>
Details &amp; Buchen Details &amp; Buchen
</referrer-link> </f:link.action>
</div> </div>
</f:then> </f:then>
<f:else> <f:else>
<div class="teaserbox__aside__top">&nbsp;</div> <div class="teaserbox__aside__top">&nbsp;</div>
<div class="teaserbox__aside__bottom"> <div class="teaserbox__aside__bottom">
<span class="searchresult-item__price">ausgebucht</span> <span class="searchresult-item__price">ausgebucht</span>
<referrer-link href="{f:uri.action(pageUid: detailPage, action: 'detail', controller: 'Product', arguments: '{product: product.uid, hotel: item.hotel.uid}')}" <f:link.action action="detail" controller="Product"
:referring-page="{ url: referringPageUrl, label: 'zurück' }" pageUid="{detailPage}"
class="button button--full searchresult-item__button" rel="nofollow">Details</referrer-link> arguments="{product: product.uid, hotel: item.hotel.uid}"
additionalParams="{ref: '{f:uri.page()}'}"
additionalAttributes="{rel: 'nofollow'}"
class="button button--full searchresult-item__button"
>
Details
</f:link.action>
</div> </div>
</f:else> </f:else>
</f:if> </f:if>
@@ -60,8 +60,6 @@
</f:link.typolink> </f:link.typolink>
</f:if> </f:if>
</div> </div>
<div class="ep-backlink" v-if="referringPage" v-cloak> <back-link></back-link>
<a :href="referringPage.url" class="button button--small">{{ referringPage.label }}</a>
</div>
{v:render.template(file: 'EXT:ep_theme/Resources/Private/Partials/Breadcrumb.html')} {v:render.template(file: 'EXT:ep_theme/Resources/Private/Partials/Breadcrumb.html')}
</div> </div>