mirror of
https://github.com/getgrav/grav.git
synced 2026-05-07 20:37:03 +02:00
Fixed missing Flex Pages in site if multi-language support has been enabled
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
1. [](#bugfix)
|
||||
* Fixed clockwork error when clearing cache
|
||||
* Fixed missing method `translated()` in `Flex Pages`
|
||||
* Fixed missing `Flex Pages` in site if multi-language support has been enabled
|
||||
|
||||
# v1.7.7
|
||||
## 02/23/2021
|
||||
|
||||
@@ -769,6 +769,9 @@ class Pages
|
||||
public function get($path)
|
||||
{
|
||||
$path = (string)$path;
|
||||
if ($path === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check for local instances first.
|
||||
if (array_key_exists($path, $this->instances)) {
|
||||
@@ -777,14 +780,26 @@ class Pages
|
||||
|
||||
$instance = $this->index[$path] ?? null;
|
||||
if (is_string($instance)) {
|
||||
/** @var Language $language */
|
||||
$language = $this->grav['language'];
|
||||
$lang = $language->getActive();
|
||||
if ($lang) {
|
||||
$instance .= ':' . $lang;
|
||||
if ($this->directory) {
|
||||
/** @var Language $language */
|
||||
$language = $this->grav['language'];
|
||||
$lang = $language->getActive();
|
||||
if ($lang) {
|
||||
$languages = $language->getFallbackLanguages($lang, true);
|
||||
$key = $instance;
|
||||
$instance = null;
|
||||
foreach ($languages as $code) {
|
||||
$test = $code ? $key . ':' . $code : $key;
|
||||
if (($instance = $this->directory->getObject($test, 'flex_key')) !== null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$instance = $this->directory->getObject($instance, 'flex_key');
|
||||
}
|
||||
}
|
||||
$instance = $this->directory ? $this->directory->getObject($instance, 'flex_key') : null;
|
||||
if ($instance) {
|
||||
|
||||
if ($instance instanceof PageInterface) {
|
||||
if ($this->fire_events && method_exists($instance, 'initialize')) {
|
||||
$instance->initialize();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user