Unify list plugins, add solution list and per-story detail page
- vitec_usecaselist: layout + record selection like marketlist - new plugin vitec_solutionlist (spec 7.13.3, key "solutions") - tx_vitec_domain_model_usecase: detail_page -> resolved detailUrl (also gives story cards in vitec_modelcard a link for the first time) - "Show Toolbar" checkbox on product/market/solution/usecase lists - spec bumped to v1.9 BREAKING: vitec_productlist and vitec_usecaselist now emit an object instead of a bare array. Consumers must read products.products and usecases.usecases. Also found: productlist had a configurable layout that was never serialised; it is emitted now, but keeps its own 0-3 vocabulary instead of grid/list/carousel. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
4ef3ad0026
commit
12eb40614b
23 files changed
+559
-28
No files matched your search
@@ -20,6 +20,11 @@ use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
* specific tt_content row (reused by ContainerChildrenProcessor for nested
|
||||
* usecase-list plugins). All serialisation is delegated to UsecaseSerializer.
|
||||
* Exception-safe.
|
||||
*
|
||||
* Payload: { "layout": "grid|list|carousel|50-50", "usecases": [ … ] }
|
||||
*
|
||||
* The editor may pick individual stories in the FlexForm; the arranged order is
|
||||
* the display order. No selection means all stories, featured first.
|
||||
*/
|
||||
class UsecaseListJsonRenderer
|
||||
{
|
||||
@@ -109,6 +114,8 @@ class UsecaseListJsonRenderer
|
||||
$flexFormData = $flexFormService->convertFlexFormContentToArray($contentElement['pi_flexform'] ?? '');
|
||||
$settings = $flexFormData['settings'] ?? [];
|
||||
$debugMode = (bool)($settings['debug'] ?? false);
|
||||
$layout = (string)($settings['layout'] ?? 'grid');
|
||||
$selectedUids = GeneralUtility::intExplode(',', (string)($settings['usecases'] ?? ''), true);
|
||||
|
||||
$qb = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(self::TABLE);
|
||||
$rows = $qb
|
||||
@@ -139,25 +146,59 @@ class UsecaseListJsonRenderer
|
||||
$detailBase = $parent !== '' ? $parent : $detailPath;
|
||||
}
|
||||
|
||||
// Editor-picked stories keep the order they were arranged in. The
|
||||
// full (small) table is fetched once and the sequence rebuilt here:
|
||||
// a SQL IN() would hand the rows back in storage order, and a story
|
||||
// that has meanwhile been hidden simply drops out. Same approach as
|
||||
// MarketListJsonRenderer.
|
||||
if ($selectedUids !== []) {
|
||||
$byUid = [];
|
||||
foreach ($rows as $r) {
|
||||
$byUid[(int)$r['uid']] = $r;
|
||||
}
|
||||
$ordered = [];
|
||||
foreach ($selectedUids as $uid) {
|
||||
if (isset($byUid[$uid])) {
|
||||
$ordered[] = $byUid[$uid];
|
||||
}
|
||||
}
|
||||
$rows = $ordered;
|
||||
}
|
||||
|
||||
$usecases = array_map(
|
||||
static function (array $u) use ($serializer, $detailBase): array {
|
||||
$item = $serializer->serializeListItem($u);
|
||||
$item['detailUrl'] = ($detailBase !== '' && ($item['slug'] ?? '') !== '')
|
||||
? $detailBase . '/' . ltrim((string)$item['slug'], '/')
|
||||
: null;
|
||||
// A story with its own detail page wins; only the others
|
||||
// fall back to the Single PID plus the slug, so nothing
|
||||
// changes for the stories that have no page assigned.
|
||||
if (($item['detailUrl'] ?? null) === null) {
|
||||
$item['detailUrl'] = ($detailBase !== '' && ($item['slug'] ?? '') !== '')
|
||||
? $detailBase . '/' . ltrim((string)$item['slug'], '/')
|
||||
: null;
|
||||
}
|
||||
return $item;
|
||||
},
|
||||
$rows
|
||||
);
|
||||
|
||||
// Envelope with the layout, matching vitec_marketlist. This changed
|
||||
// the payload from a bare array to an object - the front end has to
|
||||
// read `usecases.usecases` instead of iterating `usecases` directly.
|
||||
$response = [
|
||||
'layout' => $layout,
|
||||
'showToolbar' => (bool)($settings['showtoolbar'] ?? false),
|
||||
'usecases' => $usecases,
|
||||
];
|
||||
|
||||
if ($debugMode) {
|
||||
return (string)json_encode([
|
||||
'usecases' => $usecases,
|
||||
'debug' => ['count' => count($usecases), 'settings' => $settings],
|
||||
]);
|
||||
$response['debug'] = [
|
||||
'count' => count($usecases),
|
||||
'selected' => $selectedUids,
|
||||
'settings' => $settings,
|
||||
];
|
||||
}
|
||||
|
||||
return (string)json_encode($usecases);
|
||||
return (string)json_encode($response);
|
||||
} catch (\Throwable $e) {
|
||||
return '';
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user