Skip to content

Commit e442524

Browse files
committed
feat(blog-detail): Add edit button for contentlet in blog detail template
1 parent 9400115 commit e442524

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

examples/dotcms-symfony/assets/app.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ if (window.dotUVE) {
1414
window.dotUVE.createSubscription('changes', (changes) => {
1515
window.location.reload();
1616
})
17+
18+
document.addEventListener('click', (e) => {
19+
if (e.target.matches('button[data-contentlet]')) {
20+
const contentlet = JSON.parse(e.target.dataset.contentlet);
21+
window.dotUVE.editContentlet(contentlet);
22+
}
23+
});
24+
1725
} else {
1826
console.warn('dotUVE is not available, you might experience issues with the the Universal Visual Editor');
1927
}

examples/dotcms-symfony/templates/blog-detail.html.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<div style="max-width: 70ch; margin: 0 auto;">
2222

2323
<header>
24+
<button data-contentlet="{{ pageAsset.urlContentMap|json_encode }}">Edit</button>
2425
<h1>{{ pageAsset.urlContentMap.title }}</h1>
2526
{% if pageAsset.urlContentMap.publishDate is defined %}
2627
{% set publishDate = pageAsset.urlContentMap.publishDate // 1000 %}

0 commit comments

Comments
 (0)