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

How to create a new blueprint and link elements to it

Started by Mohamad Ghazal 9 years ago · 2 replies · 923 views
9 years ago

Hi Guys;
I'm trying to do the following:

  1. Create a new blueprint (from scratch) for my About page.
  2. Then use that blueprint for the about page ( I know the yaml and html.twig file names must be the same)

as an example:
I have in the about page a heading with a particular styling that can't just be manipulated using the # - ###### options in the markdown. So I would have to include it with a CSS class.
How do I add to blueprint a form field to ad a "H4" that takes a CSS class of (let's say) "framed".
Then, how do I include the tag on the html.twig file that take the info from that field and includes it where I put the tag on the html file.
Basically i'm trying to create a blueprint and take information from it and direct it to different sections of my page.

I'm so confused! help Please!!

9 years ago

Well, you can create a file named about.yaml inside user/themes/yourtheme/blueprints/ and fill it with the code below:

YAML
title: Article
'@extends':
    type: default
    context: blueprints://pages
form:
  fields:
    tabs:
      type: tabs
      active: 1

      fields:
        content:
          type: tab
          title: Accueil

          fields:
            header.mycustomtitle:
              type: text
              label: My custom h4 title

Then you edit about.html.twig and add this:
<h4 class="yourcustomclass">{{ page.header.mycustomtitle }}</h4>

and you are good to go.

There is several ways of creating a blueprint for your template, most of us just copy the first few lines from a blueprint in the antimatter theme and add our own field.
An alternative is to do that through the command line if that's your thing. You can therefore install the devtools plugin: bin/gpm install devtools.

And then you can generate a blueprint with the following command:
bin/plugin devtools new-blueprint

👍 1

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 Augustus, 7 months ago
7 108 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 128 7 months ago