I’m trying to put part of a blueprint into a separate blueprint, so I can import it into several others. To do this, I followed the instructions on advanced blueprint features. I created a new folder within my theme’s blueprints folder, called partials and creates a sidebar.yaml file with the tab and fields definition exactly as it previously was in my main blueprint, main_left.yaml. The main blueprint now looks like this (all content has been moved to the partial):
title: Main Left
extends@:
type: default
context: blueprints://pages
import@:
type: partials/sidebar
context: blueprints://
However, split up like this, the new tab does not appear in the admin panel.
For brevity, I’m omitting the content of sidebar.yaml, because if I add it directly into main_left.yaml (instead of the import statement), it works just fine. My assumption is that the type and/or context values are somehow wrong and Grav can’t find the partial blueprint. To be honest, from the documentation, I couldn’t understand what contextdoes . I sometimes see it in examples, sometimes not, it seems to work in both cases. Any enlightenment?
I think the problem is you don’t have the import in the right section. I’m not positive but I don’t think you can import a whole tab using a partial, just the fields.
Thank you, bbricker. So it would seem there were at least two things “wrong” with my setup:
I tried to import a whole tab which seems not to work
I did not include the form: line in my partial template
The form: seems to be required to actually make the sub-template “whole”, I guess? If I just paste its contents directly into the main template, then I don’t need the form:. Anyway, it works now.
Two follow-up question if anyone knows:
Is there more exhaustive documentation on blueprints anywhere? I have so many questions.
One of these questions: I’m still not sure how to interpret/use the blueprints:// statement.
Which is to say that streams resolve to physical locations, expanded upon in the Multisite-setup part of the docs. So the context-property works as a prefix in the case above;
Will try to import /user/plugins/admin/blueprints/partials/sidebar.yaml, since blueprints:// by defaults resolves to Admin’s /blueprints-folder.
But context: user://themes/mytheme will resolve to /user/themes/mytheme, and in conjunction with import@: type: partials/sidebar this means it tries to import /user/themes/mytheme/partials/sidebar.yaml.
There is a distinct lack of documentation about how blueprints work under the hood, it’s all in code in Rockettheme/Toolbox, and since almost all failures are silenced debugging them is difficult.
You’re a lifesaver!
I was looking for explanation of those advanced blueprint features without luck, and thanks to this post I’ve managed to actually do what I planned!