{% extends "_layouts/cp" %} {% set fullPageForm = true %} {% import "_includes/forms" as forms %} {% block content %} {{ redirectInput('settings/sections') }} {% if section.id %}{% endif %} {{ forms.textField({ first: true, label: "Name"|t('app'), instructions: "What this section will be called in the CP."|t('app'), id: 'name', name: 'name', value: section.name, errors: section.getErrors('name'), autofocus: true, required: true, }) }} {{ forms.textField({ label: "Handle"|t('app'), instructions: "How you’ll refer to this section in the templates."|t('app'), id: 'handle', name: 'handle', class: 'code', autocorrect: false, autocapitalize: false, value: section.handle, errors: section.getErrors('handle'), required: true }) }} {{ forms.checkboxField({ label: "Enable versioning for entries in this section?"|t('app'), id: 'enableVersioning', name: 'enableVersioning', checked: section.enableVersioning }) }} {{ forms.selectField({ label: "Section Type"|t('app'), instructions: "What type of section is this?"|t('app') ~ (section.id ? '
'~"Careful—changing this may result in data loss."|t('app')~'' : ''), id: 'type', name: 'type', options: typeOptions, value: section.type, toggle: true, targetPrefix: '.type-', errors: section.getErrors('type') }) }}
{% set siteRows = [] %} {% set siteErrors = section.getErrors('siteSettings') %} {% for site in craft.app.sites.getAllSites() %} {% set siteSettings = section.siteSettings[site.id] ?? null %} {% if siteSettings %} {% for attribute, errors in siteSettings.getErrors() %} {% set siteErrors = siteErrors|merge(errors) %} {% endfor %} {% endif %} {% set siteRows = siteRows|merge({ (site.handle): { heading: site.name|t('site'), enabled: include('_includes/forms/lightswitch', { name: 'sites['~site.handle~'][enabled]', on: brandNewSection or siteSettings, value: site.id, small: true }), singleUri: { value: (section.type == 'single' and siteSettings and siteSettings.uriFormat != '__home__') ? siteSettings.uriFormat, hasErrors: (section.type == 'single' and siteSettings ? siteSettings.hasErrors('uriFormat')) }, uriFormat: { value: siteSettings ? siteSettings.uriFormat, hasErrors: (section.type != 'single' and siteSettings ? siteSettings.hasErrors('uriFormat')) }, template: { value: siteSettings ? siteSettings.template, hasErrors: siteSettings ? siteSettings.hasErrors('template'), }, enabledByDefault: siteSettings ? siteSettings.enabledByDefault : true, } }) %} {% endfor %} {{ forms.editableTableField({ label: "Site Settings"|t('app'), instructions: "Choose which sites this section should be available in, and configure the site-specific settings."|t('app'), id: 'sites', name: 'sites', cols: { heading: { type: 'heading', heading: "Site"|t('app'), class: 'thin' }, enabled: { type: 'heading', class: 'thin'~(not craft.app.getIsMultiSite() ? ' hidden') }, singleUri: { type: 'singleline', heading: "URI"|t('app'), info: "What the entry URI should be for the site. Leave blank if this is the homepage."|t('app'), placeholder: "Leave blank if this is the homepage"|t('app'), code: true, class: 'type-single'~(section.type != 'single' ? ' hidden') }, uriFormat: { type: 'singleline', heading: "Entry URI Format"|t('app'), info: "What entry URIs should look like for the site. Leave blank if entries don’t have URLs."|t('app'), placeholder: "Leave blank if entries don’t have URLs"|t('app'), code: true, class: 'type-channel type-structure'~(section.type == 'single' ? ' hidden') }, template: { type: 'template', heading: "Template"|t('app'), info: "Which template should be loaded when an entry’s URL is requested."|t('app'), code: true }, enabledByDefault: { type: 'lightswitch', heading: "Default Status"|t('app'), class: 'thin type-channel type-structure'~(section.type == 'single' ? ' hidden') } }, rows: siteRows, staticRows: true, errors: siteErrors|unique }) }} {% if craft.app.getIsMultiSite() %}
{{ forms.selectField({ label: 'Propagation Method'|t('app'), instructions: 'Of the enabled sites above, which sites should entries in this section be saved to?'|t('app'), id: 'propagationMethod', name: 'propagationMethod', options: [ { value: 'none', label: 'Only save entries to the site they were created in'|t('app') }, { value: 'siteGroup', label: 'Save entries to other sites in the same site group'|t('app') }, { value: 'language', label: 'Save entries to other sites with the same language'|t('app') }, { value: 'all', label: 'Save entries to all sites enabled for this section'|t('app') }, ], value: section.propagationMethod }) }}
{% endif %}
{{ forms.textField({ label: "Max Levels"|t('app'), instructions: "The maximum number of levels this section can have. Leave blank if you don’t care."|t('app'), id: 'maxLevels', name: 'maxLevels', value: section.maxLevels, size: 5, errors: section.getErrors('maxLevels') }) }}
{% if CraftEdition == CraftPro %} {{ forms.editableTableField({ label: 'Preview Targets'|t('app'), instructions: 'Additional locations that should be available for previewing entries in this section.', id: 'previewTargets', name: 'previewTargets', cols: { label: { type: 'singleline', heading: 'Label'|t('app'), }, urlFormat: { type: 'singleline', heading: 'URL Format'|t('app'), info: 'The URL/URI to use for this target.'|t('app'), code: true, } }, rows: section.previewTargets, errors: section.getErrors('previewTargets') }) }} {% endif %} {% endblock %} {% js %} var $siteRows = $('#sites').children('tbody').children(), $lightswitches = $siteRows.children('th:nth-child(2)').children('.lightswitch'); function updateSites() { $lightswitches.each(function() { if ($(this).data('lightswitch').on) { $(this).parent().nextAll('td').removeClass('disabled').find('textarea,div.lightswitch,input').attr('tabindex', '0'); } else { $(this).parent().nextAll('td').addClass('disabled').find('textarea,div.lightswitch,input').attr('tabindex', '-1'); } }); } $lightswitches.on('change', updateSites); Garnish.$doc.ready(function() { updateSites(); }); {% if brandNewSection %} new Craft.HandleGenerator('#name', '#handle'); {% for site in craft.app.sites.getAllSites() %} new Craft.UriFormatGenerator('#name', '#sites tr[data-id="{{ site.handle }}"] textarea[name$="[singleUri]"]'); new Craft.UriFormatGenerator('#name', '#sites tr[data-id="{{ site.handle }}"] textarea[name$="[uriFormat]"]', { suffix: '/{slug}' }); new Craft.UriFormatGenerator('#name', '#sites tr[data-id="{{ site.handle }}"] textarea[name$="[template]"]', { suffix: '/_entry' }); {% endfor %} {% endif %} {% endjs %}