Upgrade to 3.0.3
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Kirby\Cms;
|
||||
|
||||
use Kirby\Toolkit\F;
|
||||
|
||||
/**
|
||||
* The Pages collection contains
|
||||
* any number and mixture of page objects
|
||||
@@ -199,18 +201,33 @@ class Pages extends Collection
|
||||
*/
|
||||
public function findById($id)
|
||||
{
|
||||
$id = trim($id, '/');
|
||||
$page = $this->get($id);
|
||||
// remove trailing or leading slashes
|
||||
$id = trim($id, '/');
|
||||
|
||||
// strip extensions from the id
|
||||
if (strpos($id, '.') !== false) {
|
||||
$info = pathinfo($id);
|
||||
|
||||
if ($info['dirname'] !== '.') {
|
||||
$id = $info['dirname'] . '/' . $info['filename'];
|
||||
} else {
|
||||
$id = $info['filename'];
|
||||
}
|
||||
}
|
||||
|
||||
// try the obvious way
|
||||
if ($page = $this->get($id)) {
|
||||
return $page;
|
||||
}
|
||||
|
||||
$multiLang = App::instance()->multilang();
|
||||
|
||||
if ($multiLang === true) {
|
||||
$page = $this->findBy('slug', $id);
|
||||
if ($multiLang === true && $page = $this->findBy('slug', $id)) {
|
||||
return $page;
|
||||
}
|
||||
|
||||
if (!$page) {
|
||||
$start = is_a($this->parent, 'Kirby\Cms\Page') === true ? $this->parent->id() : '';
|
||||
$page = $this->findByIdRecursive($id, $start, $multiLang);
|
||||
}
|
||||
$start = is_a($this->parent, 'Kirby\Cms\Page') === true ? $this->parent->id() : '';
|
||||
$page = $this->findByIdRecursive($id, $start, $multiLang);
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
Reference in New Issue
Block a user