Bug in PageList with multilingual pages (8.1)
Permalink
Hi,
I wondered why my pagelist block didn't show any results in other languages except the default one. I found in PageList.php
This always sets the search to the default siteTreeId, as getSiteTreeID() uses getSiteTreeObject() that is defined as
So this always uses the default locale. This seems to be wrong for multilingual pages, as there are different site trees for different languages.
This is a severe bug, as it prevents multilingual pages from working properly. Currently I have not found an easy way to solve it. For now I did a hack that just removes the siteTreeId from PageList if it is not set:
But I do not know if this causes errors in other places?
I wondered why my pagelist block didn't show any results in other languages except the default one. I found in PageList.php
$query->setParameter('siteTreeID', $tree->getSiteTreeID());
This always sets the search to the default siteTreeId, as getSiteTreeID() uses getSiteTreeObject() that is defined as
$locale = $this->getDefaultLocale(); if (is_object($locale)) { return $locale->getSiteTree(); }
So this always uses the default locale. This seems to be wrong for multilingual pages, as there are different site trees for different languages.
This is a severe bug, as it prevents multilingual pages from working properly. Currently I have not found an easy way to solve it. For now I did a hack that just removes the siteTreeId from PageList if it is not set:
if (is_object($this->siteTree)) { $tree = $this->siteTree; } else { //$site = \Core::make("site")->getSite(); //$tree = $site->getSiteTreeObject(); $tree = null; } // Note, we might not use this. We have to set the parameter even if we don't use it because // StackList (which extends PageList) needs to have it available. if ($tree) $query->setParameter('siteTreeID', $tree->getSiteTreeID()); if ($this->query->getParameter('cParentID') < 1) { if (!$this->includeSystemPages) { if ($tree) $query->andWhere('p.siteTreeID = :siteTreeID'); $query->andWhere('p.cIsSystemPage = :cIsSystemPage'); $query->setParameter('cIsSystemPage', false);
Viewing 15 lines of 19 lines. View entire code block.
But I do not know if this causes errors in other places?