{# ------------------------ #} {# Available Variables #} {# ------------------------ #} {# Attributes: #} {# type, name, handle, instructions, attribute, default, feed, feedData #} {# ------------------------ #} {# Fields: #} {# name, handle, instructions, feed, feedData, field, fieldClass #} {# ------------------------ #} {% import 'feed-me/_macros' as feedMeMacro %} {% import '_includes/forms' as forms %} {% if field is defined %} {% set default = default ?? { type: 'elementselect', options: { elementType: fieldClass.elementType, criteria: {'status' : null}, selectionLabel: "Default Entry"|t('feed-me'), sources: field.sources ?? '*', }, } %} {% endif %} {# Get any sub-fields for the element. Also check to go only one level deep #} {% if field is defined and isSubElementField is not defined %} {% set elementFields = [] %} {# Prevent infinite loop by only allow elements that are not the same as this #} {% for elementField in craft.feedme.getElementLayoutByField(className(field), field) %} {% if craft.feedme.supportedSubField(className(elementField)) %} {% set elementFields = elementFields|merge([ elementField ]) %} {% endif %} {% endfor %} {% endif %} {% extends 'feed-me/_includes/fields/_base' %} {% block extraSettings %}
{{ 'Data provided for this entry is:'|t('feed-me') }} {% set matchAttributes = [ { value: 'title', label: 'Title'|t('feed-me') }, { value: 'elements.id', label: 'ID'|t('feed-me') }, { value: 'slug', label: 'Slug'|t('feed-me') }, ] %} {% for field in craft.app.fields.getAllFields() %} {% if craft.feedme.fieldCanBeUniqueId(field) %} {# Check for columnSuffix (since 3.7) #} {% set suffix = field['columnSuffix'] is defined and field.columnSuffix|length ? '_' ~ field.columnSuffix : '' %} {% set matchAttributes = matchAttributes|merge({ ('field_' ~ field.handle ~ suffix): field.name }) %} {% endif %} {% endfor %} {{ forms.selectField({ name: 'options[match]', class: 'entries-field-match', value: hash_get(feed.fieldMapping, optionsPath ~ '.match') ?: '', options: matchAttributes, }) }}
{{ feedMeMacro.checkbox({ label: 'Create entries if they do not exist'|t('feed-me'), name: 'options[create]', value: 1, checked: hash_get(feed.fieldMapping, optionsPath ~ '.create') ?: '', }) }}
{% if field %}
{{ 'Section:'|t('feed-me') }} {% set sources = craft.feedme.getEntrySourcesByField(field) %} {% set sections = craft.feedme.getSelectOptions(sources, 'name', 'id', false) %} {{ forms.selectField({ name: 'options[group][sectionId]', class: '', value: hash_get(feed.fieldMapping, optionsPath ~ '.group.sectionId') ?: '', options: sections, }) }}
{% set entryTypes = [] %} {% for section in sources %} {% if section %} {% set options = craft.feedme.getSelectOptions(section.getEntryTypes(), 'name', 'id', false) %} {# We have to prefix the index, otherwise Twig doesn't maintain numbered index correctly #} {% set entryTypes = entryTypes|merge({ ('item_' ~ section.id): options }) %} {% endif %} {% endfor %} {% if sources and sources[0] %} {% set selectedTypeId = hash_get(feed.fieldMapping, optionsPath ~ '.group.typeId') ?: '' %}
{{ 'Type:'|t('feed-me') }} {{ forms.selectField({ name: 'options[group][typeId]', class: '', value: selectedTypeId, options: entryTypes['item_' ~ sources[0].id] ?? [], }) }}
{% endif %}
{% endif %} {% endblock %}