Skip to content

Commit

Permalink
Fixed equalIndex iteration
Browse files Browse the repository at this point in the history
- Fixed recently introduced equalIndex iteration in admin context
- Reduced lines of code in frontend context
  • Loading branch information
hbugdoll committed Feb 5, 2024
1 parent 4f5d83f commit fac9cdf
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/models/NavItemPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,7 @@ private function renderPlaceholderRecursive($navItemPageId, $placeholderVar, $pr
$prevIsEqual = array_key_exists($prev, $placeholders) && $placeholder['block_id'] == $placeholders[$prev]['block_id'];
$blockObject->setEnvOption('isPrevEqual', $prevIsEqual);
$blockObject->setEnvOption('isNextEqual', array_key_exists($next, $placeholders) && $placeholder['block_id'] == $placeholders[$next]['block_id']);

if (!$prevIsEqual) {
$equalIndex = 1;
} else {
$equalIndex++;
}
$blockObject->setEnvOption('equalIndex', $equalIndex);
$blockObject->setEnvOption('equalIndex', (!$prevIsEqual) ? $equalIndex = 1 : ++$equalIndex);

// render sub placeholders and set into object
$insertedHolders = [];
Expand Down Expand Up @@ -449,7 +443,7 @@ public static function getPlaceholder($placeholderVar, $prevId, NavItemPage $nav
'isLast' => ($i == $blocksCount),
'isPrevEqual' => $prevIsEqual,
'isNextEqual' => array_key_exists($next, $nav_item_page_block_item_data) && $blockItem['block_id'] == $nav_item_page_block_item_data[$next]['block_id'],
'equalIndex' => (!$prevIsEqual) ? ($equalIndex = 1) : ($equalIndex++)
'equalIndex' => (!$prevIsEqual) ? $equalIndex = 1 : ++$equalIndex
];

$item = self::getBlockItem($blockItem, $navItemPage, $envOptions);
Expand Down

0 comments on commit fac9cdf

Please sign in to comment.