diff --git a/application/src/Site/BlockLayout/TableOfContents.php b/application/src/Site/BlockLayout/TableOfContents.php index 5d80c44ce..dd1d01d11 100644 --- a/application/src/Site/BlockLayout/TableOfContents.php +++ b/application/src/Site/BlockLayout/TableOfContents.php @@ -20,7 +20,14 @@ public function form(PhpRenderer $view, SiteRepresentation $site, ) { $depth = new Number("o:block[__blockIndex__][o:data][depth]"); - $depth->setValue($block ? $block->dataValue('depth', 1) : 1); + $depthValue = 1; + if ($block) { + $blockDepth = (int) $block->dataValue('depth'); + if ($blockDepth > 1) { + $depthValue = $blockDepth; + } + } + $depth->setValue($depthValue); $depth->setAttribute('min', 1); $html = ''; @@ -53,7 +60,11 @@ public function render(PhpRenderer $view, SitePageBlockRepresentation $block, $t } $subNav = new Navigation($newPages); - $depth = $block->dataValue('depth', 1); + // Don't use dataValue's default here; we need to handle empty/non-numerics anyway + $depth = (int) $block->dataValue('depth'); + if ($depth < 1) { + $depth = 1; + } return $view->partial($templateViewScript, [ 'block' => $block,