diff --git a/CHANGELOG.md b/CHANGELOG.md index a57669a57..d9684606c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * Made `UserCollectionInderface` to extend `Countable` to get the count of existing users 1. [](#improved) * Flex admin: added default search options for flex objects + * Flex collection and object now fall back to the default template if template file doesn't exist 1. [](#bugfix) * Fixed `$grav['route']` from being modified when the route instance gets modified * Fixed Assets options array mixed with standalone priority [#2477](https://github.com/getgrav/grav/issues/2477) diff --git a/system/src/Grav/Framework/Flex/FlexCollection.php b/system/src/Grav/Framework/Flex/FlexCollection.php index ac87f7cbf..5f2cbd844 100644 --- a/system/src/Grav/Framework/Flex/FlexCollection.php +++ b/system/src/Grav/Framework/Flex/FlexCollection.php @@ -490,7 +490,12 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface $twig = $grav['twig']; try { - return $twig->twig()->resolveTemplate(["flex-objects/layouts/{$this->getFlexType()}/collection/{$layout}.html.twig"]); + return $twig->twig()->resolveTemplate( + [ + "flex-objects/layouts/{$this->getFlexType()}/collection/{$layout}.html.twig", + "flex-objects/layouts/_default/collection/{$layout}.html.twig" + ] + ); } catch (LoaderError $e) { /** @var Debugger $debugger */ $debugger = Grav::instance()['debugger']; diff --git a/system/src/Grav/Framework/Flex/FlexObject.php b/system/src/Grav/Framework/Flex/FlexObject.php index abc3d9c0c..51f622a7a 100644 --- a/system/src/Grav/Framework/Flex/FlexObject.php +++ b/system/src/Grav/Framework/Flex/FlexObject.php @@ -819,7 +819,12 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface $twig = $grav['twig']; try { - return $twig->twig()->resolveTemplate(["flex-objects/layouts/{$this->getFlexType()}/object/{$layout}.html.twig"]); + return $twig->twig()->resolveTemplate( + [ + "flex-objects/layouts/{$this->getFlexType()}/object/{$layout}.html.twig", + "flex-objects/layouts/_default/object/{$layout}.html.twig" + ] + ); } catch (LoaderError $e) { /** @var Debugger $debugger */ $debugger = Grav::instance()['debugger'];