{% extends "_layouts/cp" %} {% import "_includes/forms" as forms %} {% set fullPageForm = true %} {% set saveShortcutRedirect = continueEditingUrl %} {% set retainScrollOnSaveShortcut = true %} {% do view.setIsDeltaRegistrationActive(true) %} {% set groupHandle = group.handle %} {% set isNewCategory = category.id ? false : true %} {% set formActions = [ { label: 'Save and continue editing'|t('app'), redirect: continueEditingUrl|hash, shortcut: true, retainScroll: true, }, { label: 'Save and add another'|t('app'), redirect: nextCategoryUrl|hash, shortcut: true, shift: true, }, not isNewCategory ? { label: 'Save as a new {type}'|t('app', { type: category.lowerDisplayName(), }), params: { duplicate: '1', }, redirect: (continueEditingUrl~'#')|hash, }, not isNewCategory ? { destructive: true, label: 'Delete {type}'|t('app', { type: category.lowerDisplayName() }), action: 'categories/delete-category', redirect: 'categories#'|hash, confirm: 'Are you sure you want to delete this {type}?'|t('app', { type: category.lowerDisplayName(), }), } ]|filter %} {% hook "cp.categories.edit" %} {% block header %}
{{ block('pageTitle') }} {{ block('contextMenu') }}
{% if showPreviewBtn or shareUrl is defined %}
{% if showPreviewBtn %} {% endif %} {% if shareUrl is defined %} {% endif %}
{% endif %} {{ block('actionButton') }}
{% endblock %} {% block contextMenu %} {% if craft.app.getIsMultiSite() %} {% set parentIdParam = craft.app.request.getParam('parentId.0') ?: craft.app.request.getParam('parentId') %} {% set urlFormat = url("categories/#{groupHandle}/#{craft.app.request.getSegment(3)}/{handle}", (parentIdParam ? { parentId: parentIdParam })) %} {% include "_elements/sitemenu" with { siteIds: siteIds, selectedSiteId: category.siteId, urlFormat: urlFormat } only %} {% endif %} {% endblock %} {% block content %} {{ actionInput('categories/save-category') }} {{ redirectInput('categories/'~groupHandle) }} {{ hiddenInput('groupId', group.id) }} {% if category.id %}{{ hiddenInput('categoryId', category.id) }}{% endif %} {% if craft.app.getIsMultiSite() %}{{ hiddenInput('siteId', category.siteId) }}{% endif %}
{{ fieldsHtml|raw }}
{# Give plugins a chance to add other things here #} {% hook "cp.categories.edit.content" %} {% endblock %} {% block details %}
{{ forms.textField({ label: "Slug"|t('app'), siteId: category.siteId, id: 'slug', name: 'slug', autocorrect: false, autocapitalize: false, value: category.slug, placeholder: "Enter slug"|t('app'), errors: (category.getErrors('slug')|merge(category.getErrors('uri'))) }) }} {% if parentOptionCriteria is defined %} {{ forms.elementSelectField({ label: "Parent"|t('app'), id: 'parentId', name: 'parentId', elementType: elementType, selectionLabel: "Choose"|t('app'), sources: ['group:'~group.uid], criteria: parentOptionCriteria, limit: 1, elements: (parent is defined and parent ? [parent]), errors: category.getErrors('parent') }) }} {% endif %} {{ forms.lightswitchField({ label: "Enabled"|t('app'), id: 'enabled', name: 'enabled', on: category.enabled }) }}
{% if category.id %}
{{ "Date Created"|t('app') }}
{{ category.dateCreated|datetime('short') }}
{{ "Date Updated"|t('app') }}
{{ category.dateUpdated|datetime('short') }}
{% endif %} {# Give plugins a chance to add other stuff here #} {% hook "cp.categories.edit.details" %} {% endblock %} {% if not category.slug %} {% js %} window.slugGenerator = new Craft.SlugGenerator('#title', '#slug', { charMap: {{ craft.cp.getAsciiCharMap(category.site.language)|json_encode|raw }} }); {% endjs %} {% endif %}