Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

Modular page blueprints load, but their custom fields don’t appear in Admin

blueprints first-time

Solved by Augustus View solution

Started by Augustus 7 months ago · 7 replies · 108 views
7 months ago

I’m working on a custom theme and creating new modular sections. Grav does detect the modular types (they appear in the template selection dropdown), and the .html.twig and .yaml files are all in the correct folders:

  • user/themes/nemora/templates/modular/hero.html.twig

  • user/themes/nemora/blueprints/modular/hero.yaml

However, the issue is that the custom fields defined in the modular blueprint do not appear in the normal Admin view when editing the modular page. Only the default fields show up, even though the YAML blueprint extends the correct page type and has valid syntax.

Important details:

  • The page blueprint and the theme blueprint do show correctly in Admin

  • Only the modular blueprint’s fields fail to appear

  • The modular type itself is listed and selectable

  • Cache has been cleared multiple times

  • YAML indentation and naming match the template exactly

So Grav recognizes the modular template but ignores the blueprint fields.

What could cause Admin to skip rendering the modular blueprint fields even though the file structure is correct and the blueprint is loaded?

Links to the relevant files (with the same structure)

https://drive.proton.me/urls/GJAMQZ7K6R#Zol0AWA8ABCS

7 months ago

@aev, I cannot reproduce the issue...

I've copied your blueprint from Proton into blueprint /user/themes/quark/blueprints/modular/hero.yaml and I get the following result in Admin.

image|542x500

So your pages do show up in Admin and the data is saved properly into hero.md...

7 months ago Solution

@pamtbaau Thank you for the quick response!
The issue was with blueprints directory.
Here is a detailed solution for anyone discovering this too:
/forum/forms-blueprints/module-blueprint-t4095

7 months ago

@aev:
The issue was with blueprints directory.

What exactly was the issue with the blueprints directory?

7 months ago

My directory was

TXT
├── blueprints
│   ├── modular
│   │   └── hero.yaml
│   └── pages
│       └── knowledge.yaml

It now works as expected when I moved modular inside pages

TXT
├── blueprints
│   └── pages
│       ├── modular
│       │   └── hero.yaml
│       └── knowledge.yaml

I didn’t include the knowledge file when sharing as I thought it didn’t matter. It did 😃

7 months ago

@aev, That still doesn't clarify it for me... Anyway, your issue has been solved.

7 months ago

Grav skips blueprints inside the theme/blueprints/modular folder as long as the theme/blueprints/pages folder exists, even if this folder is empty.

When creating blueprints in a theme, IF the pages directory is exists (even if empty), the modular blueprints must be nested in the pages directory. Else they can be in the blueprints/modular directory .

7 months ago

@aev, I'm puzzled...

Using the "One-Page Site" (uses a modular home page) skeleton, I have...

  • created an empty folder /user/themes/quark/blueprints/pages/

    TXT
    user/themes/quark/blueprints
    ├── blog.yaml
    ├── default.yaml
    ├── item.yaml
    ├── modular
    │   ├── features.yaml
    │   ├── hero.yaml
    │   └── text.yaml
    ├── modular.yaml
    ├── pages                <== Empty folder
    └── partials
      └── blog-bits.yaml
    
  • Added an extra field in /user/themes/quark/blueprints/modules/text.yaml

    YAML
    title: Text
    '@extends': default
    
    form:
    fields:
      tabs:
        fields:
          content:
            fields:
              header.media_order:
                label: Page Media (first one will be displayed next to your content)
              header.image_align:
                type: select
                label: Image position
                classes: fancy
                default: left
                options:
                  'left': 'Left'
                  'right': 'Right'
              header.myfield:
                  type: text
                  label: My Field
                  description: 'This is My Field'
    
  • Field 'myfield' is perfectly shown in Admin at the bottom of tab "Content" and its data is saved into the page file.
    image|684x146

Maybe it has to do with how you "extend" the blueprint. IIRC, your extention section, at the top of the module, had something with "pages" in it.

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1135 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 61 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 134 6 months ago
Forms & Blueprints · by Julien, 7 months ago
10 128 7 months ago
Forms & Blueprints · by Rayburn Davis, 7 months ago
4 92 7 months ago