From af5e077f81e46561d19a5656690e9dae8ebd6af1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Schwei=C3=9Finger?= Date: Mon, 7 Jul 2025 09:52:06 +0200 Subject: [PATCH] Add details to entryBlueprintFound event --- content/collections/extending-docs/events.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/content/collections/extending-docs/events.md b/content/collections/extending-docs/events.md index 4c9512041..6d0268f16 100644 --- a/content/collections/extending-docs/events.md +++ b/content/collections/extending-docs/events.md @@ -374,6 +374,25 @@ public function handle(EntryBlueprintFound $event) } ``` +You can also use this to replace the whole blueprint content. +An example would be if you have a collection that should use a blueprint from another collection. + +```php +use Statamic\Facades\Blueprint; + +public function handle(EntryBlueprintFound $event) +{ + if ($event->blueprint->fullyQualifiedHandle() === 'collections.subpages.subpage') { + $pageBlueprint = Blueprint::find('collections.pages.page'); + + $event->blueprint->setContents($pageBlueprint->contents()); + + // The entrys blueprint would be `subpage`, but the blueprint + // fields etc. would be the same as in `page`. + } +} +``` + ### EntryCreated `Statamic\Events\EntryCreated`