Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the type: blocks field work with {{ block() }}. #8

Merged
merged 1 commit into from
Nov 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base-2016/page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{{ record.body }}

{# If there are repeaters, we should output them. #}
{% with { 'record': record, 'common': false, 'repeaters': true, 'exclude': ['teaser', 'body', 'image'] } %}
{% with { 'record': record, 'common': false, 'repeaters': true, 'blocks': true, 'exclude': ['teaser', 'body', 'image'] } %}
{{ block('sub_fields', 'partials/_sub_fields.twig') }}
{% endwith %}

Expand Down
9 changes: 5 additions & 4 deletions base-2016/partials/_sub_fields.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
ContentType definitions as well as passed in variables.
- The last section is where the actual looping is done, and the relevant
{{ block() }} function is called, for the 'ContentType fields',
'repeater fields' and 'template fields' in turn.
'repeater fields', 'block fields' and 'template fields' in turn.

Read the relevant section in the documentation on usage of this
functionality: https://docs.bolt.cm/templating
Expand Down Expand Up @@ -63,8 +63,9 @@

{% endif %}

{# Finally, the repeaters #}
{% if repeaters|default(false) == true and record.fieldtype(key) == "repeater" %}
{# Finally, the repeaters and blocks #}
{% if (repeaters|default(false) == true and record.fieldtype(key) == "repeater") or
(blocks|default(false) == true and record.fieldtype(key) == "block") %}

{% if (global.request.get('_route') != "preview") %}

Expand All @@ -86,7 +87,7 @@
fixed properly for Bolt 4, but for now we just output a notice, and prevent crashes.
See also: https://github.com/bolt/bolt/issues/6605 #}
<p>
Unfortunately, Repeater fields do not work correctly with the generic
Unfortunately, Repeater and Block fields do not work correctly with the generic
<code>block()</code> function, when using Preview. To view these fields, please
save the record, and view the page normally.
</p>
Expand Down
2 changes: 1 addition & 1 deletion base-2016/record.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{# Output all fields, in the order as defined in the contenttype.
To change the generated html and configure the options, see:
https://docs.bolt.cm/templating #}
{% with { 'record': record, 'extended': true, 'repeaters': true } %}
{% with { 'record': record, 'extended': true, 'repeaters': true, 'blocks': true } %}
{{ block('sub_fields', 'partials/_sub_fields.twig') }}
{% endwith %}

Expand Down
9 changes: 5 additions & 4 deletions skeleton/partials/_sub_fields.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
ContentType definitions as well as passed in variables.
- The last section is where the actual looping is done, and the relevant
{{ block() }} function is called, for the 'ContentType fields',
'repeater fields' and 'template fields' in turn.
'repeater fields', 'block fields' and 'template fields' in turn.

Read the relevant section in the documentation on usage of this
functionality: https://docs.bolt.cm/templating
Expand Down Expand Up @@ -63,8 +63,9 @@

{% endif %}

{# Finally, the repeaters #}
{% if repeaters|default(false) == true and record.fieldtype(key) == "repeater" %}
{# Finally, the repeaters and blocks #}
{% if (repeaters|default(false) == true and record.fieldtype(key) == "repeater") or
(blocks|default(false) == true and record.fieldtype(key) == "block") %}

{% if (global.request.get('_route') != "preview") %}

Expand All @@ -86,7 +87,7 @@
fixed properly for Bolt 4, but for now we just output a notice, and prevent crashes.
See also: https://github.com/bolt/bolt/issues/6605 #}
<p>
Unfortunately, Repeater fields do not work correctly with the generic
Unfortunately, Repeater and Block fields do not work correctly with the generic
<code>block()</code> function, when using Preview. To view these fields, please
save the record, and view the page normally.
</p>
Expand Down
2 changes: 1 addition & 1 deletion skeleton/record.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{# Output all fields, in the order as defined in the contenttype.
To change the generated html and configure the options, see:
https://docs.bolt.cm/templating #}
{% with { 'record': record, 'common': true, 'extended': true, 'repeaters': true } %}
{% with { 'record': record, 'common': true, 'extended': true, 'repeaters': true, 'blocks': true } %}
{{ block('sub_fields', 'partials/_sub_fields.twig') }}
{% endwith %}

Expand Down