{% extends "_layouts/cp" %} {% import "_includes/forms" as forms %} {% set sectionHandle = section.handle %} {% set isSingle = section.type == 'single' %} {% set isVersion = className(entry) == 'craft\\models\\EntryVersion' %} {% set isDraft = entry.id and className(entry) == 'craft\\models\\EntryDraft' %} {% set canPublish = currentUser.can('publishEntries'~permissionSuffix) %} {% set canSave = ( (entry.id or currentUser.can('createEntries'~permissionSuffix)) and (not entry.id or not entry.enabled or canPublish) and (isSingle or entry.authorId == currentUser.id or currentUser.can('publishPeerEntries'~permissionSuffix)) ) %} {% hook "cp.entries.edit" %} {% block header %} {{ block('pageTitle') }} {{ block('contextMenu') }}
{% if showPreviewBtn or shareUrl is defined %} {% if showPreviewBtn %}
{{ "Live Preview"|t('app') }}
{% endif %} {% if shareUrl is defined %} {{ 'Share'|t('app') }} {% endif %}
{% endif %} {{ block('actionButton') }} {% endblock %} {% block contextMenu %} {% if entry.id or showSites %} {% include "entries/_revisions" %} {% endif %} {% endblock %} {% block actionButton %} {% if isDraft %} {{ redirectInput(baseCpEditUrl~'/drafts/'~entry.draftId) }}
{# Are they allowed to publish this draft? #} {% set canPublishDraft = ( canPublish and (isSingle or entry.authorId == currentUser.id or currentUser.can('publishPeerEntries'~permissionSuffix)) and (entry.creatorId == currentUser.id or currentUser.can('publishPeerEntryDrafts'~permissionSuffix)) ) %} {# Are they allowed to delete this draft? #} {% set canDeleteDraft = ( entry.creatorId == currentUser.id or currentUser.can('deletePeerEntryDrafts'~permissionSuffix) ) %} {% if canPublishDraft or canDeleteDraft %} {% endif %}
{% elseif isVersion %} {# Are they allowed to publish changes? #} {% if canPublish and (isSingle or entry.authorId == currentUser.id or currentUser.can('publishPeerEntries'~permissionSuffix)) %} {{ redirectInput(entry.getCpEditUrl()) }}
{% endif %} {% elseif canSave %} {{ redirectInput('entries/'~sectionHandle) }}
{% else %} {{ redirectInput(baseCpEditUrl~'/drafts/{draftId}') }} {% endif %} {% endblock %} {% block content %} {% if not isVersion %} {% if entry.id %}{% endif %} {% if craft.app.getIsMultiSite() %}{% endif %} {% else %} {% endif %}
{% include "entries/_fields" with { static: isVersion } %}
{# Give plugins a chance to add other things here #} {% hook "cp.entries.edit.content" %} {% endblock %} {% block details %} {% if not isSingle or canPublish %}
{% if not isSingle %} {% if showEntryTypes %} {{ forms.selectField({ label: "Entry Type"|t('app'), id: 'entryType', name: 'typeId', value: entryType.id, options: entryTypeOptions }) }} {% endif %} {{ forms.textField({ label: "Slug"|t('app'), siteId: entry.siteId, id: 'slug', name: 'slug', value: entry.slug, placeholder: "Enter slug"|t('app'), errors: (not isVersion ? entry.getErrors('slug')|merge(entry.getErrors('uri'))), disabled: isVersion }) }} {% if parentOptionCriteria is defined %} {{ forms.elementSelectField({ label: "Parent"|t('app'), id: 'parentId', name: 'parentId', elementType: elementType, selectionLabel: "Choose"|t('app'), sources: ['section:'~section.id], criteria: parentOptionCriteria, limit: 1, elements: (parent is defined and parent ? [parent]), errors: entry.getErrors('parent') }) }} {% endif %} {% if CraftEdition == CraftPro and currentUser.can('editPeerEntries'~permissionSuffix) %} {{ forms.elementSelectField({ label: "Author"|t('app'), id: 'author', name: 'author', elementType: userElementType, selectionLabel: "Choose"|t('app'), criteria: authorOptionCriteria, limit: 1, elements: (author is defined and author ? [author]) }) }} {% endif %} {{ forms.dateTimeField({ label: "Post Date"|t('app'), id: 'postDate', name: 'postDate', value: (entry.postDate ? entry.postDate : null), errors: entry.getErrors('postDate'), disabled: isVersion }) }} {{ forms.dateTimeField({ label: "Expiry Date"|t('app'), id: 'expiryDate', name: 'expiryDate', value: (entry.expiryDate ? entry.expiryDate : null), errors: entry.getErrors('expiryDate'), disabled: isVersion }) }} {% endif %} {% if canPublish %} {{ forms.lightswitchField({ label: "Enabled"|t('app'), id: 'enabled', name: 'enabled', on: entry.enabled, disabled: isVersion }) }} {% endif %} {% if showSites %} {{ forms.lightswitchField({ label: "Enabled for site"|t('app'), id: 'enabledForSite', name: 'enabledForSite', on: entry.enabledForSite, disabled: isVersion }) }} {% endif %}
{% if entry.id %}
{{ "Created at"|t('app') }}
{{ entry.dateCreated|datetime('short') }}
{{ "Updated at"|t('app') }}
{{ entry.dateUpdated|datetime('short') }}
{% if entry.revisionNotes %}
{{ "Notes"|t('app') }}
{{ entry.revisionNotes }}
{% endif %}
{% endif %} {% endif %} {# Give plugins a chance to add other things here #} {% hook "cp.entries.edit.details" %} {% if not isDraft and not isVersion and canSave and section.enableVersioning %}
{% endif %} {% endblock %} {% if not entry.slug %} {% js %} window.slugGenerator = new Craft.SlugGenerator('#title', '#slug'); {% endjs %} {% endif %}