{% extends "_layouts/cp" %} {% set fullPageForm = true %} {% set docsUrl = 'http://craftcms.com/docs/categories' %} {% macro urlFormatText(locale, categoryGroup, name, value) %} {% from "_includes/forms" import text, errorList %} {% set errors = categoryGroup.getErrors(name~'-'~locale.id) %}
{{ text({ id: name~'-'~locale.id, class: 'code ltr', name: name~'['~locale.id~']', value: (value != '__home__' ? value : null), errors: errors }) }}
{{ errorList(errors) }} {% endmacro %} {% import "_includes/forms" as forms %} {% from _self import urlFormatText %} {% block content %} {% if categoryGroup.id %}{% endif %}
{{ forms.textField({ first: true, label: "Name"|t, instructions: "What this category group will be called in the CP."|t, id: 'name', name: 'name', value: categoryGroup.name, errors: categoryGroup.getErrors('name'), autofocus: true, required: true, translatable: true }) }} {{ forms.textField({ label: "Handle"|t, instructions: "How you’ll refer to this category group in the templates."|t, id: 'handle', class: 'code', name: 'handle', value: categoryGroup.handle, errors: categoryGroup.getErrors('handle'), required: true }) }}
{{ forms.checkboxField({ label: "Categories in this group have their own URLs"|t, id: 'hasUrls', name: 'hasUrls', checked: categoryGroup.hasUrls, toggle: 'url-settings' }) }}
{% set urlFormatInput %} {% if craft.isLocalized() %} {% endif %} {% for locale in craft.i18n.getSiteLocales() %} {% if craft.isLocalized() %} {% endif %} {% endfor %}
{{ "Top-Level Categories"|t }} {{ "Nested Categories"|t }}
{{ locale.id }} {% set value = (categoryGroup.locales[locale.id] is defined ? categoryGroup.locales[locale.id].urlFormat : null) %} {{ _self.urlFormatText(locale, categoryGroup, 'urlFormat', value) }} {% set value = (categoryGroup.locales[locale.id] is defined ? categoryGroup.locales[locale.id].nestedUrlFormat : '{parent.uri}/{slug}') %} {{ _self.urlFormatText(locale, categoryGroup, 'nestedUrlFormat', value) }}
{% endset %} {{ forms.field({ label: "Category URL Formats"|t, instructions: "What the category URLs should look like. {slug} is required, but it can also include any category properties."|t, required: true, errors: categoryGroup.getErrors('urlFormat') }, urlFormatInput) }} {{ forms.textField({ label: "Category Template"|t, instructions: "The template to use when a category’s URL is requested."|t, id: 'template', class: 'ltr', name: 'template', value: categoryGroup.template, errors: categoryGroup.getErrors('template') }) }}
{{ forms.textField({ label: "Max Levels"|t, instructions: "The maximum number of levels this category group can have. Leave blank if you don’t care."|t, id: 'maxLevels', name: 'maxLevels', value: categoryGroup.maxLevels, size: 5, errors: categoryGroup.getErrors('maxLevels') }) }}
{% endblock %} {% if not categoryGroup.handle %} {% includejs %} new Craft.HandleGenerator('#name', '#handle'); {% for locale in craft.i18n.getSiteLocales() %} {% if categoryGroup.locales[locale.id] is not defined or not categoryGroup.locales[locale.id].urlFormat %} new Craft.EntryUrlFormatGenerator('#name', '#urlFormat-{{ locale.id }}', { suffix: '/{slug}' }); {% endif %} {% endfor %} {% endincludejs %} {% endif %}