feat: conditional rendering of 'courses' teaser in travelinfo

This commit is contained in:
Björn Fromme
2024-11-25 15:09:09 +01:00
parent f30c887a12
commit ae7e8b2d45
4 changed files with 21 additions and 4 deletions
+1 -1
View File
@@ -170,7 +170,7 @@ routeEnhancers:
extension: EpProducts extension: EpProducts
plugin: travelinfo plugin: travelinfo
limitToPages: limitToPages:
- 2712 - 2736
routes: routes:
- -
routePath: '/{travelinfo}/{traveldate}' routePath: '/{travelinfo}/{traveldate}'
@@ -60,8 +60,10 @@ class TravelinfoController extends ActionController
/** @var Date $date */ /** @var Date $date */
$date = $this->dateRepository->findForProductAndDate($product, $travelDate)->getFirst(); $date = $this->dateRepository->findForProductAndDate($product, $travelDate)->getFirst();
$hasCourses = 0 < count($date->getServicesGeneral('KUR'));
$this->view->assign('travelinfo', $travelinfo); $this->view->assign('travelinfo', $travelinfo);
$this->view->assign('date', $date); $this->view->assign('date', $date);
$this->view->assign('hasCourses', $hasCourses);
} }
} }
@@ -462,9 +462,15 @@ class Date extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/** /**
* @return array $servicesGeneral * @return array $servicesGeneral
*/ */
public function getServicesGeneral() public function getServicesGeneral($token = null)
{ {
return unserialize($this->servicesGeneral); $services = unserialize($this->servicesGeneral);
if (null !== $token) {
return $services[$token] ?? [];
}
return $services;
} }
/** /**
@@ -113,7 +113,16 @@
</div> </div>
<div class="container px-4 lg:px-24 flex flex-col space-y-16 pb-16"> <div class="container px-4 lg:px-24 flex flex-col space-y-16 pb-16">
<f:for each="{travelinfo.teasers}" as="teaser"> <f:for each="{travelinfo.teasers}" as="teaser">
<f:render section="Teaser" arguments="{_all}"/> <f:if condition="{teaser.category} == 'course'">
<f:then>
<f:if condition="{hasCourses}">
<f:render section="Teaser" arguments="{_all}"/>
</f:if>
</f:then>
<f:else>
<f:render section="Teaser" arguments="{_all}"/>
</f:else>
</f:if>
</f:for> </f:for>
</div> </div>
<div id="goodtoknow" class="bg-ep-primary-bg"> <div id="goodtoknow" class="bg-ep-primary-bg">