[5.x] Add support for collection entry blueprints loaded via addons#11674
[5.x] Add support for collection entry blueprints loaded via addons#11674xenco wants to merge 2 commits intostatamic:5.xfrom
Conversation
|
It looks like this has caused a bunch of test failures. Would you be able to take a look? Most of them are the same error: |
|
I think the errors are caused by where I initially placed the changes. Although the modifications were only relevant for collections, they unintentionally affected all blueprints. Sorry if this caused confusion or still is not the right way of doing things. It's my first time working with the core. |
|
No worries! |
|
How is this different than the addon use the blueprint found event? |
|
Hi @edalzell, if existing functionality already covers my use case, could you please provide me with an example? Just registering the blueprints to a namespace does not work for me. I tried multiple variations of namespace and path. Still only the top-level blueprints are registered. |
|
Hi, while I like this change very much since I have the same problem as well it leads to inconsistent behavior. This changed blueprint will NOT be used and will be overwritten by the plugins blueprint. I would argue that similar to similar to Laravel Standard and how Fieldsets are handled the customized Blueprint should land in resources/blueprints/vendors/myPackage/collections/pages/custompage.yaml and override plugins blueprint. |
Addons can currently listen to the For example: <?php
namespace App\Listeners;
use Statamic\Events\EntryBlueprintFound;
class AddExtraFields
{
/**
* Create the event listener.
*/
public function __construct()
{
//
}
/**
* Handle the event.
*/
public function handle(EntryBlueprintFound $event): void
{
$event->blueprint->ensureField('example_field', [
'type' => 'text',
'display' => 'Example field',
]);
}
}Addons can also register publishables, allowing users to copy files (like blueprint YAML files) using Laravel's The |
|
Thanks for the PR and sorry for the delay. Your addon could publish a blueprint yaml file to |

This PR enables addons to supply predefined blueprints for existing collections.
Closes statamic/ideas#1327.
Problem
Statamic previously introduced addon blueprint loading support (see #9324), but it was limited to top-level blueprints only. It did not allow addons to add blueprints to existing collections—for example, adding an extra blueprint to the "pages" collection to support features like a page builder with addon-provided and autoloaded fieldsets.
Solution
This PR extends the blueprint loading mechanism, enabling addons to load entry blueprints for any existing collection. To make use of this functionality, addons must follow this directory structure:
Which will result in the addon blueprints being visible and selectable for that collections entries.