Reusing & extending blueprints
Fields, sections, tabs and entire blueprint layouts can be reused within your blueprints. If you want, you can even create a complete component system to apply to multiple projects.
While the examples used below all refer to page blueprints, you can also
- reuse field and field group mixins in file and user blueprints and field sections,
- reuse all section type mixins in user blueprints and
- reuse layout mixins in user blueprints.
Reusing and extending single fields
You can create single fields in /site/blueprints/fields
and then reuse them, for example this structure field:
Reuse in your page blueprint:
Simple reuse
Extended reuse
Reusing and extending field groups
Create a field definition of type group
with your fields:
Reuse in your page blueprint:
Simple reuse
Extended reuse
Reusing and extending sections
You can create section blueprints (predefined sections) for pages, files and fields, which you can reuse in your blueprints.
Let's look at an example for a section of type: pages
. Suppose you want to have multiple page lists in the blog.yml
blueprint for drafts, unlisted and listed articles. Instead of defining the same section over and over again, you can create a basic section definition like this:
In your blog.yml
blueprint, you can now create different pages sections based on this section blueprint:
In the example, we have created three sections that extend the articles section blueprint, one for drafts, one for unlisted subpages and one for listed subpages.
In the same way, you can create a files section:
And reuse it in your blueprint:
Check out the Starterkit section and page blueprints for more examples of section reuse.
Extending tabs
Instead of repeating yourself and adding the same tab configuration to multiple blueprints, you can keep single tab definitions in /site/blueprints/tabs
and reuse them in every blueprint. A typical use case would be a SEO tab that always contains the same fields.
Let's start with the SEO tab mixin:
This is how you can use it in a blueprint:
You can see how this instantly reduces your blueprint code and leaves you with the customized parts for each blueprint type. Using such tab mixins extensively will clean your blueprints, and also makes it a lot easier to maintain them afterwards.
If you want to overwrite parts of the mixin you can use the extends
option instead.
Reusing and extending entire layouts
Reuse in your page blueprint:
Simple reuse
Extended reuse
Unset parts of extended blueprints
When you reuse mixins for blueprints, such as field definitions or entire tabs, you can unset the parts that you don't want/need.
Then in the extending blueprint …
Since 3.6.4
Multiple extends at once
You can reuse multiple blueprints at once. So you can develop a more modular system by writing less and non-repetitive code.
Then in the extending blueprint …