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
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
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?
Is that your whole blueprint file?
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.
Here’s an example I have that worked.
title: Main File
title: New Tab Name
Like I said though, I’m not sure if you can import a whole tab. You may be able to, but I wasn’t able to get that to work either.
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
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
If it can help anyone regarding domsson’s last question (meaning and use of
blueprints:// aka PHP streams) :
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
blueprints:// by defaults resolves to Admin’s
context: user://themes/mytheme will resolve to
/user/themes/mytheme, and in conjunction with
import@: type: partials/sidebar this means it tries to import
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!