From f87c5a3c5018516915ab2759f355acc85568eaba Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Wed, 11 Sep 2019 14:32:49 +0200 Subject: [PATCH] Simplify "fields" a bit. --- public/theme/skeleton/record.twig | 2 +- templates/helpers/_fields.twig | 19 ++----------------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/public/theme/skeleton/record.twig b/public/theme/skeleton/record.twig index 01d05dda2..a134c0be3 100644 --- a/public/theme/skeleton/record.twig +++ b/public/theme/skeleton/record.twig @@ -16,7 +16,7 @@ {# Output all fields, in the order as defined in the content type. To change the generated html and configure the options, see: https://docs.bolt.cm/templating #} - {% with { 'record': record, 'common': true, 'extended': true, 'repeaters': true, 'blocks': true, 'exclude': [record|image.fieldname] } %} + {% with { 'record': record, 'exclude': [record|image.fieldname|default()] } %} {{ block('sub_fields', 'partials/_sub_fields.twig') }} {% endwith %} diff --git a/templates/helpers/_fields.twig b/templates/helpers/_fields.twig index e2887a132..14968645c 100644 --- a/templates/helpers/_fields.twig +++ b/templates/helpers/_fields.twig @@ -7,8 +7,7 @@ - The first section initializes the variables and settings, both from the 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', 'block fields' and 'template fields' in turn. + {{ block() }} function is called, for the 'ContentType fields' in turn. Read the relevant section in the documentation on usage of this functionality: https://docs.bolt.cm/templating @@ -22,6 +21,7 @@ {% block sub_fields %} {# SECTION 1: INITIALIZATION #} {%- apply spaceless %} + {# Set up the array of fieldnames that should be iterated. We do this by looping over _all_ the fields, and skipping those in the 'omittedkeys' array. #} {% set omittedkeys = [ 'id', 'slug', 'datecreated', 'datechanged', 'datepublish', @@ -61,19 +61,4 @@ {% endfor %} - {# We do the same for the templatefields, if set and not empty. #} - {% if record.hasField('templateFields') %} - {# Note: This needs to be expanded upon!! For better detection the 'virtual' - content type for the templatefields should know about the types of fields. #} - {% set templatefields_field_types = attribute(record.contentType.templatefields.first, 'fields') %} - - {% for key, field in record.templateFields|filter(key => key not in omittedkeys) %} - - {% set type = attribute(attribute(templatefields_field_types, key), 'type') %} - {{ block('common_fields') }} - {{ block('extended_fields') }} - - {% endfor %} - - {% endif %} {% endblock sub_fields %}