underr
October 5, 2017, 1:50pm
1
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?
underr
October 5, 2017, 2:16pm
3
{% 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 }) %}
underr
October 5, 2017, 3:31pm
5
Yeah, i know this way and use it now, by i want to better understand blueprints.
paul
October 5, 2017, 3:56pm
6
I think t’s because of the yaml: true or the string validation
underr
October 5, 2017, 4:25pm
7
I tried to remove this lines - unfortunally, it is not helped.
It is looks like parsing issue.
paul
October 5, 2017, 4:57pm
8
can you try:
default: '''taxonomy@.category'': ''notes'''
underr
October 5, 2017, 5:25pm
9
And this i tried - nothing changed…
paul
October 5, 2017, 6:41pm
10
with and without yaml: true?
underr
October 6, 2017, 8:30am
11
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.
paul
October 6, 2017, 9:13am
12
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'
underr
October 6, 2017, 4:32pm
13
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
paul
October 7, 2017, 9:50am
14
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
underr
October 7, 2017, 10:46am
15
O yeah! It’s looks like decision of my question. Thank you!