{% extends "_layouts/cp" %} {% set docsUrl = 'http://buildwithcraft.com/docs/sections-and-entries#sections' %} {% import "_includes/forms" as forms %} {% macro urlFormatText(sectionType, locale, section, name, value) %} {% from "_includes/forms" import text, errorList %} {% set errors = section.getErrors(name~'-'~locale.id) %}
{{ text({ id: sectionType~'-'~name~'-'~locale.id, class: 'code ltr', name: 'types['~sectionType~']['~name~']['~locale.id~']', value: (value != '__home__' ? value : null), errors: errors }) }}
{{ errorList(errors) }} {% endmacro %} {% macro urlFormatInput(sectionType, brandNewSection, section) %} {% if craft.isLocalized() or sectionType == 'structure' %} {% if sectionType == 'structure' %} {% if craft.isLocalized() %} {% endif %} {% endif %} {% for locale in craft.i18n.getSiteLocales() %} {% if craft.isLocalized() %} {% endif %} {% if sectionType == 'structure' %} {% endif %} {% endfor %}
{{ "Top-Level Entries"|t }} {{ "Nested Entries"|t }}
{{ locale.id }} {% set value = ((section.type == sectionType or sectionType != 'single') and section.locales[locale.id] is defined ? section.locales[locale.id].urlFormat : null) %} {{ _self.urlFormatText(sectionType, locale, section, 'urlFormat', value) }} {% set value = ((section.type == 'structure') and section.locales[locale.id] is defined ? section.locales[locale.id].nestedUrlFormat : '{parent.uri}/{slug}') %} {{ _self.urlFormatText(sectionType, locale, section, 'nestedUrlFormat', value) }}
{% else %} {% set locale = craft.i18n.getPrimarySiteLocale() %} {% set value = ((section.type == sectionType or sectionType != 'single') and section.locales[locale.id] is defined ? section.locales[locale.id].urlFormat : null) %} {{ _self.urlFormatText(sectionType, locale, section, 'urlFormat', value) }} {% endif %} {% endmacro %} {% macro hasUrlsField(sectionType, section) %} {% from "_includes/forms" import checkboxField %} {{ checkboxField({ label: "Entries in this section have their own URLs"|t, id: sectionType~'-hasUrls', name: 'types['~sectionType~'][hasUrls]', checked: section.hasUrls, toggle: sectionType~'-url-settings' }) }} {% endmacro %} {% macro templateField(sectionType, section) %} {% from "_includes/forms" import textField %} {{ textField({ label: "Entry Template"|t, instructions: (sectionType == 'single' ? "The template to use when the entry’s URL is requested."|t : "The template to use when an entry’s URL is requested."|t), id: sectionType~'-template', class: 'ltr', name: 'types['~sectionType~'][template]', value: section.template, errors: section.getErrors('template') }) }} {% endmacro %} {% from _self import urlFormatInput, hasUrlsField, templateField %} {% set content %}
{% if section.id %}{% endif %} {{ forms.textField({ first: true, label: "Name"|t, instructions: "What this section will be called in the CP."|t, id: 'name', name: 'name', value: section.name, errors: section.getErrors('name'), autofocus: true, required: true, translatable: true }) }} {{ forms.textField({ label: "Handle"|t, instructions: "How you’ll refer to this section in the templates."|t, id: 'handle', class: 'code', name: 'handle', value: section.handle, errors: section.getErrors('handle'), required: true }) }} {% if craft.isLocalized() %} {% set localesInput %} {% for locale in craft.i18n.getSiteLocales() %} {% set localeSelected = (brandNewSection or section.locales[locale.id] is defined) %} {% endfor %}
{{ "Locale"|t }} {{ "Default Status"|t }}
{{ forms.checkbox({ id: 'locale-'~locale.id, name: 'locales[]', value: locale.id, checked: localeSelected, toggle: '.for-locale-'~locale.id }) }}
{{ forms.lightswitch({ name: 'defaultLocaleStatuses['~locale.id~']', on: (brandNewSection or not section.locales[locale.id] is defined or section.locales[locale.id].enabledByDefault), small: true }) }}
{% endset %} {{ forms.field({ label: "Which locales should entries in this section target?"|t }, localesInput) }} {% endif %} {{ forms.selectField({ label: "Section Type"|t, instructions: "What type of section is this?"|t ~ (section.id ? '
'~"Careful—changing this may result in data loss."|t~'' : ''), id: 'type', name: 'type', options: typeOptions, value: section.type, toggle: true, targetPrefix: 'type-', errors: section.getErrors('type') }) }}
{% if canBeSingle %} {% endif %} {% set urlFormatParams = { label: "Entry URL Format"|t, instructions: "What the entry URLs should look like. You can include tags that output entry properties, such as {ex1} or {ex2}."|t({ ex1: '{slug}', ex2: '{postDate|date("Y")}' }), required: true, errors: section.getErrors('urlFormat') } %} {% if canBeChannel %} {% endif %} {% if canBeStructure %} {% endif %}
{% if CraftEdition >= CraftClient %} {{ forms.checkboxField({ label: "Enable versioning for entries in this section?"|t, id: 'enableVersioning', name: 'enableVersioning', checked: section.enableVersioning }) }} {% endif %}
{% endset %} {% set js %} {% if not section.handle %}new Craft.HandleGenerator('#name', '#handle');{% endif %} {% for locale in craft.i18n.getSiteLocales() %} {% if section.locales[locale.id] is not defined or not section.locales[locale.id].urlFormat %} new Craft.EntryUrlFormatGenerator('#name', '#single-urlFormat-{{ locale.id }}'); new Craft.EntryUrlFormatGenerator('#name', '#channel-urlFormat-{{ locale.id }}', { suffix: '/{slug}' }); new Craft.EntryUrlFormatGenerator('#name', '#structure-urlFormat-{{ locale.id }}', { suffix: '/{slug}' }); {% endif %} {% endfor %} {% if brandNewSection %} new Craft.EntryUrlFormatGenerator('#name', '#single-template'); new Craft.EntryUrlFormatGenerator('#name', '#channel-template', { suffix: '/_entry' }); new Craft.EntryUrlFormatGenerator('#name', '#structure-template', { suffix: '/_entry' }); {% endif %} {% endset %} {% includeJs js %}