Importing blueprint does not work - what does context do / mean?


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
  type: default
  context: blueprints://pages

  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? :slight_smile:


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.

Main File

title: Main File
    type: default
    context: blueprints://pages

          type: tab
          title: New Tab Name

              type: section
              title: images
              underline: true
                type: partials/paritial-fields
                context: blueprints://

Partial File

      type: text
      label: Title
      type: list
      label: Images
          type: text
          label: Image

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.

1 Like

Thank you, bbricker. So it would seem there were at least two things “wrong” with my setup:

  1. I tried to import a whole tab which seems not to work
  2. 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:

  1. Is there more exhaustive documentation on blueprints anywhere? I have so many questions.
  2. One of these questions: I’m still not sure how to interpret/use the blueprints:// statement.



If it can help anyone regarding domsson’s last question (meaning and use of blueprints:// aka PHP streams) :