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.

Archive

Twig Reference for Blueprint Fields YAML

Started by Muut Archive 9 years ago · 1 replies · 520 views
9 years ago

Hi guys, I need a little help. I made a blueprint for a modular element, and added some buttons:

YAML
header.buttons:
  name: buttons
  type: list
  style: vertical
  label: Buttons
  fields:
    .text:
      type: text
      label: Text
    .url:
      type: text
      label: URL
    .primary:
      type: toggle
      label: Primary
      highlight: 1
      default: 1
      options:
          1: 'Yes'
          0: 'No'
      validate: 
          type: bool

Now, in my twig template, how do I access the text and URL fields? I currently have it set to :

TWIG
<a href="{{page.header.buttons.url}}">{{page.header.buttons.text}}</a>

But my html output returns an empty <a> tag.

I think im getting the syntax wrong on how to drill down into my frontmatter to extract the right data. But I can't for the life of me find any docs on this specifically.

9 years ago

I think you've duplicated the header field in your blueprint. page.header will already get you into the fields so change header.buttons to just buttons and then your twig code should work as is.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1297 9 years ago
Archive · by Muut Archive, 9 years ago
2 894 9 years ago
Archive · by Muut Archive, 9 years ago
2 4024 9 years ago
Archive · by Muut Archive, 9 years ago
1 2899 9 years ago
Archive · by Muut Archive, 9 years ago
3 1082 9 years ago