Skip to content

Commit

Permalink
Restore compatibility with Contao 4.11
Browse files Browse the repository at this point in the history
Disable the useFolderUrl setting for each page model while creating the alias
  • Loading branch information
dmolineus committed Jul 15, 2021
1 parent 85e2307 commit c691f06
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions TL_ROOT/system/modules/backboneit_trueurl/TrueURLBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

use Contao\Backend;
use Contao\BackendUser;
use Contao\Config;
use Contao\Database;
use Contao\Input;
use Contao\PageModel;
use Contao\Session;
use Contao\System;

Expand Down Expand Up @@ -247,14 +249,16 @@ public function keyAutoInherit() {
}

public function saveAlias($strAlias) {
$this->folderUrlConfig = \Contao\Config::get('folderUrl');
\Contao\Config::set('folderUrl', false);
$this->folderUrlConfig = Config::get('folderUrl');
Config::set('folderUrl', false);
$GLOBALS['TL_HOOKS']['loadPageDetails'][self::class] = [self::class, 'setPageDetails'];

return trim($strAlias, ' /');
}

public function resetFolderUrlConfig($strAlias) {
\Contao\Config::set('folderUrl', $this->folderUrlConfig);
Config::set('folderUrl', $this->folderUrlConfig);
unset($GLOBALS['TL_HOOKS']['loadPageDetails'][self::class]);
return $strAlias;
}

Expand Down Expand Up @@ -355,8 +359,10 @@ public function onsubmitPage($objDC) {

$strAlias = $objDC->activeRecord->alias;
if(!strlen($strAlias)) {
$this->saveAlias($strAlias);
$tl_page = new tl_page();
$strAlias = $tl_page->generateAlias('', $objDC);
$this->resetFolderUrlConfig($strAlias);
}

$this->updateRootInherit($objDC);
Expand Down Expand Up @@ -396,6 +402,11 @@ public function generateArticle($objDC) {
$objDC->activeRecord->alias = $strAlias;
}

public static function setPageDetails(array $parents, PageModel $pageModel)
{
$pageModel->useFolderUrl = false;
}

protected $objTrueURL;

public function __construct() {
Expand Down

0 comments on commit c691f06

Please sign in to comment.