diff --git a/Classes/Controller/PageGridController.php b/Classes/Controller/PageGridController.php index d85eda0b2..58288712f 100644 --- a/Classes/Controller/PageGridController.php +++ b/Classes/Controller/PageGridController.php @@ -14,6 +14,7 @@ use Kitodo\Dlf\Pagination\PageGridPagination; use Kitodo\Dlf\Pagination\PageGridPaginator; use Psr\Http\Message\ResponseInterface; +use TYPO3\CMS\Core\Cache\CacheManager; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -44,14 +45,24 @@ public function mainAction(): ResponseInterface return $this->htmlResponse(); } + // Access cachemanager for pagegrid + $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('tx_dlf_pagegrid'); + $cacheKey = $this->document->getCurrentDocument()->recordId; + $cachedData = $cache->get($cacheKey); + $entryArray = []; - $numPages = $this->document->getCurrentDocument()->numPages; - // Iterate through visible page set and display thumbnails. - for ($i = 1; $i <= $numPages; $i++) { - $foundEntry = $this->getEntry($i); - $foundEntry['state'] = ($i == $this->requestData['page']) ? 'cur' : 'no'; - $entryArray[] = $foundEntry; + if ($cachedData) { + $entryArray = $cachedData; // Load from cache + } else { + $numPages = $this->document->getCurrentDocument()->numPages; + // Iterate through visible page set and display thumbnails. + for ($i = 1; $i <= $numPages; $i++) { + $foundEntry = $this->getEntry($i); + $foundEntry['state'] = ($i == $this->requestData['page']) ? 'cur' : 'no'; + $entryArray[] = $foundEntry; + } + $cache->set($cacheKey, $entryArray); } // Get current page from request data because the parameter is shared between plugins diff --git a/ext_localconf.php b/ext_localconf.php index 09914da11..5a1ccbc5a 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -138,6 +138,15 @@ if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tx_dlf_doc']['options']['defaultLifeTime'])) { $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tx_dlf_doc']['options']['defaultLifeTime'] = 86400; // 86400 seconds = 1 day } +// Use Caching Framework for PageGrid $entryArray caching +$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tx_dlf_pagegrid'] ??= []; + +if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tx_dlf_pagegrid']['backend'])) { + $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tx_dlf_pagegrid']['backend'] = 'TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend'; +} +if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tx_dlf_pagegrid']['options']['defaultLifeTime'])) { + $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tx_dlf_pagegrid']['options']['defaultLifeTime'] = 86400; // 86400 seconds = 1 day +} // Add new renderType for TCA fields. $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][] = [ 'nodeName' => 'editInProductionWarning',