Blueprints issue?

Hi!
I want to have page header as below that will be make by blueprint

title: notes
content:
    items:
        '@taxonomy.category': notes

I create a simple blueprint:

title: notes
'@extends':
    type: default
    context: blueprints://pages

    form:
      fields:
        tabs:
          type: tabs
          active: 1

          fields:

            notes:
              type: tab
              title: Custom

              fields:
                header.content.items:
                  type: textarea
                  yaml: true
                  label: Items
                  default: {'taxonomy@.category': notes}
                  validate:
                    required: true
                    type: string

And when i create a page and look to my custom tab i see

'@taxonomy.category': notes

But after i save this page i see wrong code which not works:

title: test
content:
    items: '''@taxonomy.category'': notes'

What i do wrong?

P.S: Sorry for my English)

What does your twig file look like?

{% extends 'partials/base.html.twig' %}

{% block content %}

{% set collection = page.collection() %}

<div class="pure-g">
<div class="pure-u-1 pure-u-md-16-24 padding transition">
    <h2 class="text-center">Last Notes</h2>
    {% for child in collection %}
        {%
            set image = child.media['_header.jpg']
            ? child.media['_header.jpg']
            : child.media.images|first
        %}
        {% include 'partials/article.html.twig'  with {'child': child, 'image':image} %}
        {% if not loop.last %}
            <div>
                <hr class="note-hr"/>
            </div>
        {% endif %}
    {% endfor %}
    {% if config.plugins.pagination.enabled and collection.params.pagination %}
        <div class="pure-g">
            <div class="pure-u-1">
                {% include 'partials/pagination.html.twig' with {'base_url':page.url } %}
            </div>
        </div>
    {% endif %}
</div>
<div class="pure-u-1 pure-u-md-8-24 padding transition">
     {% include 'partials/sidebar.html.twig' %}
</div>
</div>
{% endblock %}

It works good if i write
items:
’@taxonomy.category’: notes
by hand.
I just want to figure out how to write more complex structures in blueprints

I can’t say I know how to do that with the blueprints. But if you aren’t going to be changing the collection, you could use twig to get the information you need. Since the twig file will always be linked to that blueprint, it will accomplish the same thing.

{% set collection = page.collection({ 'items': { '@taxonomy': { 'category': 'notes' } }, 'pagination': true }) %}

Yeah, i know this way and use it now, by i want to better understand blueprints.

I think t’s because of the yaml: true or the string validation

I tried to remove this lines - unfortunally, it is not helped.
It is looks like parsing issue.

can you try:

default: '''taxonomy@.category'': ''notes'''

And this i tried - nothing changed…

with and without yaml: true?

Yes - it does not affect. When i just create a new page i see the correct code (like taxonomy@.category: notes or 'taxonomy@.category': notes) in my custom tab. But when i save this page the code writes into a page with additioal quotes and without right indentation.

It’s because you have to store a colon in your yaml file, and it’s a special character for yaml.

If your value is stored like that:

'''@page'': ''/blog'''

It will be displayed like that in your template, which is correct.

'@page': '/blog'

Ok, i understand it.
If generalize the question I want to know how can i will add indents and new lines using blueprint…
If i edit page content in expert mode and write content: {items: {taxonomy@: { 'category': 'notes'}}} after saving it writes good with correct indent:

content:
    items:
        taxonomy@:
            category: notes

And I think method like this should be for blueprint

take a look at the multilevel field.
You could also indent by writing

header.content.items.taxonomy@:
  type: array
  label: choose taxonomy

and then you write category and notes

2 Likes

O yeah! It’s looks like decision of my question. Thank you!