Skip to content
● Critical PHP security fixes are out: update PHP on your Grav sites. What to do →

Flex Objects blueprints in theme or plugin

Solved by beejay41 View solution

Started by beejay41 6 years ago · 1 replies · 908 views
6 years ago

As the main deliverable for a website, the theme is an ideal place to install new Flex Object blueprints. However, just adding blueprints/flex-objects/newobject.yaml doesn't appear to be enough to register the new object type.

The Flex Object README refers to onFlexInit, however the source code states // This event is for backwards compatibility only, do not use it!.

So what is the correct way to register Flex Object blueprints in a theme or plugin? Is there an example somewhere that I've missed?

Regards BJ

6 years ago Solution

I was beginning to think that this a was a stupid question.

The solution turns out to be simple. A new flex object can be added to a basic plugin by adding blueprints/flex-objects/newobject.yaml as I though, but the plugin needs the following, before the blueprint is discovered:

PHP
    public $features = [
    'blueprints' => 100,
];

I've seen this code in other plugins, but not found it mentioned in the documentation.
I doesn't appear this trick works in a template.

Suggested topics

Topic Participants Replies Views Activity
Support · by webmasterodp, 2 weeks ago
4 248 2 weeks ago
Support · by nwhitfield, 2 weeks ago
2 214 2 weeks ago
Support · by stell, 4 weeks ago
5 458 3 weeks ago
Support · by gravinator, 2 months ago
5 638 3 weeks ago
Support · by Gravver, 1 month ago
6 430 4 weeks ago