Skip to content

Commit

Permalink
Prevent broken links generated by Contao 4.10
Browse files Browse the repository at this point in the history
  • Loading branch information
dmolineus committed Dec 15, 2020
1 parent 7ca3611 commit f8332ab
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -457,19 +457,19 @@ public function compileNavigationItem(array $arrPage, $blnForwardResolution = tr
}

if(!$objNext->numRows) {
$arrPage['href'] = $this->generateFrontendUrl($arrPage, null, null, true);
$arrPage['href'] = $this->generatePageUrl($arrPage);

} elseif($objNext->type == 'redirect') {
$arrPage['href'] = $this->encodeEmailURL($objNext->url);
$arrPage['target'] = $objNext->target ? LINK_NEW_WINDOW : '';

} else {
$arrPage['tid'] = $objNext->id;
$arrPage['href'] = $this->generateFrontendUrl($objNext->row(), null, null, true);
$arrPage['href'] = $this->generatePageUrl($objNext->row());
}
} else {
$arrPage['tid'] = $arrPage['jumpTo'];
$arrPage['href'] = $this->generateFrontendUrl($arrPage, null, null, true);
$arrPage['href'] = $this->generatePageUrl($arrPage);
}
break;

Expand All @@ -491,7 +491,7 @@ public function compileNavigationItem(array $arrPage, $blnForwardResolution = tr
case 'error_401':
case 'error_403':
case 'error_404':
$arrPage['href'] = $this->generateFrontendUrl($arrPage, null, null, true);
$arrPage['href'] = $this->generatePageUrl($arrPage);
break;
}

Expand Down Expand Up @@ -693,4 +693,13 @@ protected function executeItemHook(array &$arrPage, $blnForce = false) {
}
}

private function generatePageUrl(array $arrPage)
{
$pageModel = \Contao\PageModel::findByPk($arrPage['id']);
if ($pageModel) {
$pageModel->getFrontendUrl();
}

return null;
}
}

0 comments on commit f8332ab

Please sign in to comment.