Last active
December 3, 2023 15:59
-
-
Save piotrpog/a2a03474783cf5d267bcd55095bd0a9c to your computer and use it in GitHub Desktop.
Quick edit link component for Craft CMS 3. More info on http://craftsnippets.com/articles/quick-edit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# v4 #} | |
{% if currentUser and currentUser.can('accessCp') and not craft.app.request.isLivePreview %} | |
{% set element = element|default(craft.app.urlManager.matchedElement) %} | |
{% if element and element.isEditable %} | |
{% set editLink = element.getCpEditUrl() %} | |
{% if element.draftId is defined and element.draftId is not null %} | |
{% set editLink = editLink ~ '&draftId='~ element.draftId %} | |
{% endif %} | |
{% set editText = 'edit'|t %} | |
{% else %} | |
{% set editLink = cpUrl() %} | |
{% set editText = 'control panel'|t %} | |
{% endif %} | |
<aside class="cs-edit-link"> | |
<a href="{{editLink}}" target="_blank" class="button is-info">{{editText}}</a> | |
</aside> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment