Grid(s): Why VITEC -> 11838 (3 Benefit-Karten) + 11839 (1), // Finder-Intro + Comparison-Text, Products-Intro -> 11840 (IGC + IQS4), // Solutions-Intro -> 11841 (2 Solution-Karten) const ORDER = [11620, 11621, 11622, 11838, 11839, 11627, 11628, 11629, 11840, 11632, 11841]; $apply = in_array('--apply', $argv, true); $root = null; $dir = __DIR__; for ($i = 0; $i < 5; $i++) { if (is_file($dir . '/config/system/settings.php')) { $root = $dir; break; } $dir = dirname($dir); } if ($root === null) { exit("Could not locate project root above " . __DIR__ . "\n"); } $settings = require $root . '/config/system/settings.php'; $db = $settings['DB']['Connections']['Default']; $pdo = new PDO( sprintf('mysql:host=%s;port=%s;dbname=%s;charset=utf8mb4', $db['host'] ?? 'localhost', $db['port'] ?? 3306, $db['dbname'] ?? ''), $db['user'] ?? '', $db['password'] ?? '', [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC] ); echo ($apply ? 'APPLY' : 'INSPECT') . " ยท pid " . PID . "\n\n"; $rows = $pdo->query('SELECT uid, CType, colPos, LEFT(header,40) h FROM tt_content WHERE deleted = 0 AND pid = ' . PID)->fetchAll(); $byUid = []; foreach ($rows as $row) { $byUid[(int)$row['uid']] = $row; } foreach (array_merge(ORDER, DUPLICATES) as $uid) { if (!isset($byUid[$uid])) { exit("ABBRUCH: uid $uid fehlt auf der Seite - erst klaeren.\n"); } } $tail = []; foreach ($pdo->query('SELECT uid, CType, LEFT(header,40) h FROM tt_content WHERE deleted = 0 AND pid = ' . PID . ' AND colPos = 0 ORDER BY sorting, uid') as $row) { $uid = (int)$row['uid']; if (!in_array($uid, ORDER, true) && !in_array($uid, DUPLICATES, true)) { $tail[] = $uid; echo "tail: #$uid {$row['CType']} \"{$row['h']}\"\n"; } } echo "\n1) " . count(DUPLICATES) . " Duplikat-Karten soft-loeschen: " . implode(',', DUPLICATES) . "\n"; echo "2) colPos0 neu sortieren:\n"; $sequence = array_merge(ORDER, $tail); foreach ($sequence as $i => $uid) { $r = $byUid[$uid]; printf(" %3d. #%-6d %-22s %s\n", $i + 1, $uid, $r['CType'], $r['h']); } if (!$apply) { echo "\nInspect only - mit --apply schreiben.\n"; exit(0); } $pdo->exec('UPDATE tt_content SET deleted = 1, tstamp = UNIX_TIMESTAMP() WHERE uid IN (' . implode(',', DUPLICATES) . ')'); $sorting = 0; $stmt = $pdo->prepare('UPDATE tt_content SET sorting = ?, tstamp = UNIX_TIMESTAMP() WHERE uid = ?'); foreach ($sequence as $uid) { $sorting += 256; $stmt->execute([$sorting, $uid]); } echo "\nGeschrieben. Danach: vendor/bin/typo3 cache:flush\n";