Enable limiting of dates on detail pages according to teasers
This commit is contained in:
@@ -27,6 +27,7 @@ namespace EP\EpTheme\ViewHelpers\Uri;
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
use EP\EpEvents\Domain\Model\Hotel;
|
||||
use EP\EpProducts\Domain\Model\Product;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
@@ -42,12 +43,12 @@ class ProductViewHelper extends AbstractViewHelper
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('product', Product::class, 'The product', true);
|
||||
$this->registerArgument('hotel', 'mixed', 'The hotel');
|
||||
$this->registerArgument('linkHotel', 'bool', 'Whether to link the hotel', false, false);
|
||||
$this->registerArgument('referringPageUid', 'int', 'Uid of the referring page');
|
||||
$this->registerArgument('defaultDetailPageUid', 'int', 'Uid of default page for product details');
|
||||
$this->registerArgument('origin', 'string', 'Origin of the link');
|
||||
$this->registerArgument('product', 'array', 'The product');
|
||||
$this->registerArgument('hotel', 'array', 'The hotel');
|
||||
$this->registerArgument('dateFrom', 'string', 'Date to limit table on detail page by (Y-m-d)');
|
||||
$this->registerArgument('dateTo', 'string', 'Date to limit table on detail page by (Y-m-d)');
|
||||
$this->registerArgument('forceHotelUid', 'bool', 'Whether to force link a hotel');
|
||||
$this->registerArgument('slug', 'string', 'Slug to append to resulting uri');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,35 +64,45 @@ class ProductViewHelper extends AbstractViewHelper
|
||||
)
|
||||
{
|
||||
$product = $arguments['product'];
|
||||
$hotel = $arguments['hotel'];
|
||||
|
||||
if ($product->getDetailPage()) {
|
||||
$linkArguments = null;
|
||||
|
||||
if ($arguments['forceHotelUid']) {
|
||||
$linkArguments = [
|
||||
'product' => $product['uid'],
|
||||
'hotel' => $hotel['uid'],
|
||||
];
|
||||
} elseif ($arguments['dateFrom'] || $arguments['dateTo']) {
|
||||
$linkArguments = [
|
||||
'dateFrom' => $arguments['dateFrom'],
|
||||
'dateTo' => $arguments['dateTo'],
|
||||
];
|
||||
}
|
||||
|
||||
if (null !== $linkArguments) {
|
||||
$uri = $renderingContext
|
||||
->getControllerContext()
|
||||
->getUriBuilder()
|
||||
->reset()
|
||||
->setTargetPageUid($product['detailPage'])
|
||||
->uriFor('detail', $linkArguments, 'Product', 'epproducts', 'product_detail')
|
||||
;
|
||||
} else {
|
||||
/** @var ContentObjectRenderer $contentObject */
|
||||
$contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
|
||||
return $contentObject->typoLink_URL(
|
||||
$uri = $contentObject->typoLink_URL(
|
||||
[
|
||||
'parameter' => $product->getDetailPage(),
|
||||
'parameter' => $product['detailPage'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$pageUid = $arguments['defaultDetailPageUid'];
|
||||
$uriArguments = [ 'product' => $product ];
|
||||
if ((int) $arguments['referringPageUid'] > 0) {
|
||||
$uriArguments['referringPageUid'] = $arguments['referringPageUid'];
|
||||
if ($arguments['slug']) {
|
||||
$uri .= $arguments['slug'].'/';
|
||||
}
|
||||
if ($arguments['origin'] !== null) {
|
||||
$uriArguments['origin'] = $arguments['origin'];
|
||||
}
|
||||
if ((bool) $arguments['linkHotel'] && $arguments['hotel'] !== null) {
|
||||
$uriArguments['hotel'] = $arguments['hotel'];
|
||||
}
|
||||
return $renderingContext
|
||||
->getControllerContext()
|
||||
->getUriBuilder()
|
||||
->reset()
|
||||
->setTargetPageUid($pageUid)
|
||||
->uriFor('detail', $uriArguments, 'Product', 'epproducts', 'product_detail')
|
||||
;
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+14
-3
@@ -78,6 +78,14 @@
|
||||
daytrip: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
dateFrom: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
dateTo: {
|
||||
type: String,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -91,12 +99,15 @@
|
||||
this.datesShow = true;
|
||||
this.priceTableShow = false;
|
||||
this.detailShow = false;
|
||||
const data = $.param({
|
||||
'tx_epproducts_ajax[paCode]': this.$store.state.config.paCode,
|
||||
'tx_epproducts_ajax[dateFrom]': this.dateFrom,
|
||||
'tx_epproducts_ajax[dateTo]': this.dateTo
|
||||
});
|
||||
axios({
|
||||
url: this.uris['dates'],
|
||||
method: 'post',
|
||||
data: {
|
||||
paCode: this.$store.state.config.paCode
|
||||
}
|
||||
data: data
|
||||
}).then(response => {
|
||||
const json = response.data;
|
||||
if (json.dates.length === 1) {
|
||||
|
||||
@@ -6,30 +6,9 @@
|
||||
|
||||
<f:section name="Teaser">
|
||||
<div class="teaserbox teaserbox--product teaserbox--flippable">
|
||||
<f:if condition="{teaser.forceHotelUid}">
|
||||
<f:then>
|
||||
<f:link.action
|
||||
pageUid="{teaser.product.detailPage}"
|
||||
action="detail"
|
||||
controller="Product"
|
||||
arguments="{product: teaser.product.uid, hotel: teaser.hotel.uid}"
|
||||
extensionName="epproducts"
|
||||
pluginName="product_detail"
|
||||
class="teaserbox__flip"
|
||||
title="{teaser.product.name}">
|
||||
<f:render section="Inner" arguments="{_all}"/>
|
||||
</f:link.action>
|
||||
</f:then>
|
||||
<f:else>
|
||||
<f:variable name="teaserUrl" value="{f:uri.typolink(parameter: teaser.product.detailPage)}"/>
|
||||
<f:if condition="{slug}">
|
||||
<f:variable name="teaserUrl" value="{teaserUrl}{slug}/"/>
|
||||
</f:if>
|
||||
<a href="{teaserUrl}" class="teaserbox__flip" title="{teaser.product.name}">
|
||||
<f:render section="Inner" arguments="{_all}"/>
|
||||
</a>
|
||||
</f:else>
|
||||
</f:if>
|
||||
<a href="{ep:uri.product(forceHotelUid: teaser.forceHotelUid, product: teaser.product, hotel: teaser.hotel, dateFrom: dateFrom, dateTo: dateTo, slug: slug)}" class="teaserbox__flip" title="{teaser.product.name}">
|
||||
<f:render section="Inner" arguments="{_all}"/>
|
||||
</a>
|
||||
</div>
|
||||
</f:section>
|
||||
|
||||
|
||||
@@ -5,17 +5,7 @@
|
||||
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers">
|
||||
|
||||
<f:section name="Teaser">
|
||||
<f:if condition="{teaser.forceHotelUid}">
|
||||
<f:then>
|
||||
<f:variable name="teaserUrl" value="{f:uri.action(pageUid: teaser.product.detailPage, action: 'detail', controller: 'Product', arguments: '{product: teaser.product.uid, hotel: teaser.hotel.uid}', extensionName: 'epproducts', pluginName: 'product_detail')}"/>
|
||||
</f:then>
|
||||
<f:else>
|
||||
<f:variable name="teaserUrl" value="{f:uri.typolink(parameter: teaser.product.detailPage)}"/>
|
||||
<f:if condition="{slug}">
|
||||
<f:variable name="teaserUrl" value="{teaserUrl}{slug}/"/>
|
||||
</f:if>
|
||||
</f:else>
|
||||
</f:if>
|
||||
{ep:uri.product(forceHotelUid: teaser.forceHotelUid, product: teaser.product, hotel: teaser.hotel, dateFrom: dateFrom, dateTo: dateTo, slug: slug) -> f:variable(name: 'teaserUrl')}
|
||||
<f:render section="Inner" arguments="{_all}"/>
|
||||
</f:section>
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
:bus-pro-id="{product.busProId -> f:format.raw()}"
|
||||
name-internal="{product.nameInternal -> f:format.raw()}"
|
||||
:daytrip="{product.daytrip -> v:variable.convert(type: 'int')}"
|
||||
date-from="{dateFrom}"
|
||||
date-to="{dateTo}"
|
||||
inline-template>
|
||||
<article>
|
||||
<f:render partial="Product/HeaderDetail" arguments="{_all}"/>
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
<f:for each="{teasers}" as="teaser">
|
||||
<f:if condition="{settings.layout} == 'rows'">
|
||||
<f:then>
|
||||
<f:render partial="Product/TeaserWide" section="Teaser" arguments="{teaser: teaser}"/>
|
||||
<f:render partial="Product/TeaserWide" section="Teaser" arguments="{teaser: teaser, dateFrom: dateFrom, dateTo: dateTo}"/>
|
||||
</f:then>
|
||||
<f:else>
|
||||
<div class="col-md-3">
|
||||
<f:render partial="Product/Teaser" section="Teaser" arguments="{teaser: teaser}"/>
|
||||
<f:render partial="Product/Teaser" section="Teaser" arguments="{teaser: teaser, dateFrom: dateFrom, dateTo: dateTo}"/>
|
||||
</div>
|
||||
</f:else>
|
||||
</f:if>
|
||||
|
||||
Reference in New Issue
Block a user