{% extends "_layouts/cp" %} {% import "_includes/forms" as forms %} {% set crumbs = [ { label: "Settings"|t, url: url('settings') }, { label: "Sections"|t, url: url('settings/sections') } ] %} {% if section is not defined and sectionId is defined %} {% set section = craft.sections.getSectionById(sectionId) %} {% if not section %}{% exit 404 %}{% endif %} {% endif %} {% set isNewSection = (section is not defined or not section.id) %} {% if isNewSection %} {% set title = "Create a new section"|t %} {% else %} {% set title = section.name %} {% endif %} {% set tabs = { settings: { label: "Settings"|t, url: '#section-settings' }, fieldlayout: { label: "Field Layout"|t, url: '#section-fieldlayout' } } %} {% set content %}
{% if not isNewSection %}{% 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 is defined ? section.name : null), errors: (section is defined ? section.getErrors('name') : null), 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 is defined ? section.handle : null), errors: (section is defined ? section.getErrors('handle') : null), required: true }) }} {{ forms.textField({ label: "“Title” Label"|t, instructions: "What do you want the entries’ “Title” fields to be labeled?"|t, id: 'titleLabel', name: 'titleLabel', value: (section is defined ? section.titleLabel : 'Title'), errors: (section is defined ? section.getErrors('titleLabel') : null), required: true, translatable: true }) }} {% if craft.hasPackage('Localize') %} {% set localesInput %} {% for locale in craft.i18n.getSiteLocales() %}
{{ forms.checkbox({ label: locale.name~' ('~locale.id~')', name: 'locales[]', value: locale.id, checked: (section is not defined or (section is defined and section.locales[locale.id] is defined)), toggle: 'urlFormatRow-'~locale.id }) }}
{% endfor %} {% endset %} {{ forms.field({ label: "Locales"|t, instructions: "Which locales should this section be enabled in?"|t }, localesInput) }} {% endif %}
{{ forms.checkboxField({ label: "Entries in this section have their own URLs"|t, name: 'hasUrls', checked: (section is defined ? section.hasUrls : true), toggle: 'has-urls-setting' }) }}
{% macro urlFormatInput(locale, section) %} {% import "_includes/forms" as forms %} {% set errors = section ? section.getErrors('urlFormat-'~locale.id) : null %}
{{ forms.text({ id: 'urlFormat-'~locale.id, class: 'code', name: 'urlFormat['~locale.id~']', value: (section is defined and section.locales[locale.id] is defined ? section.locales[locale.id].urlFormat : null), errors: errors }) }}
{{ forms.errorList(errors) }} {% endmacro %} {% from _self import urlFormatInput %} {% set urlFormatField %} {% if craft.hasPackage('Localize') %} {% for locale in craft.i18n.getSiteLocales() %} {% endfor %}
{% else %} {{ urlFormatInput(craft.i18n.getPrimarySiteLocale(), (section is defined ? section : null)) }} {% endif %} {% endset %} {{ forms.field({ label: "Entry URL Format"|t, instructions: "What the entry URLs should look like. {slug} is required, but it can also include any entry properties, e.g. {postDate.year}."|t, required: true, errors: (section is defined ? section.getErrors('urlFormat') : null) }, urlFormatField) }} {{ forms.textField({ label: "Entry Template"|t, instructions: "The template to use when an entry’s URL is requested."|t, id: 'template', name: 'template', value: (section is defined ? section.template : null), errors: (section is defined ? section.getErrors('template') : null) }) }}

{% endset %} {% set js %} {% if section is not defined or not section.handle %}new Craft.HandleGenerator('#name', '#handle');{% endif %} {% for locale in craft.i18n.getSiteLocales() %} {% if section is not defined or section.locales[locale.id] is not defined or not section.locales[locale.id].urlFormat %} new Craft.EntryUrlFormatGenerator('#name', '#urlFormat-{{ locale.id }}'); {% endif %} {% endfor %} {% endset %} {% includeJs js %}