How would I add a link, in a "template" UI element, that opens an entry in a slideout? #15203
-
What the title says 🙂 I want to add a UI element with "template" type in my field layout, and in that twig template include a link to an entry, that opens in a slideout. I might also want to do that in a custom widget. How would I go about that? |
Beta Was this translation helpful? Give feedback.
Answered by
brandonkelly
Jun 14, 2024
Replies: 1 comment
-
You can do that like so: {% set buttonId = "button#{random()}" %}
<button id="{{ buttonId }}" class="btn">Edit entry</button>
{% js %}
(() => {
const id = '{{ buttonId|namespaceInputId }}';
$(`#${id}`).on('activate', () => {
Craft.createElementEditor('craft\\elements\\Entry', {
elementId: 100,
});
});
})();
{% endjs %} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
brandonkelly
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can do that like so: