Skip to content

Instantly share code, notes, and snippets.

@jenswittmann
Last active March 20, 2026 10:22
Show Gist options
  • Select an option

  • Save jenswittmann/55cfa84b33c01949c29fd8ac6eb5ac6e to your computer and use it in GitHub Desktop.

Select an option

Save jenswittmann/55cfa84b33c01949c29fd8ac6eb5ac6e to your computer and use it in GitHub Desktop.
MODX Resource Edit Button for frontend usage
[[!+modx.user.id:gt=`0`:then=`
<style>
.modx-edit-button {
position: fixed;
left: 15px;
bottom: 15px;
z-index: 9999;
font-size: .75rem;
font-weight: bold;
padding: 11px 20px;
background-color: #f1f1f1;
border-radius: 4px;
opacity: 0.1;
transition: 0.3s;
&:hover {
opacity: 1;
}
}
</style>
<a href="[[++manager_url]]?a=resource/update&id=[[*id]]" class="modx-edit-button">✏️</a>
`]]
{if $_modx->hasSessionContext('mgr')}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/ryersondmp/sa11y@latest/dist/css/sa11y.min.css"/>
<script src="https://cdn.jsdelivr.net/combine/gh/ryersondmp/sa11y@latest/dist/js/lang/de.umd.js,gh/ryersondmp/sa11y@latest/dist/js/sa11y.umd.min.js"></script>
<script>
Sa11y.Lang.addI18n(Sa11yLangDe.strings);
const sa11y = new Sa11y.Sa11y({
checkRoot: "body",
customChecks: "listen",
});
document.addEventListener('sa11y-custom-checks', () => {
const emptyElements = sa11y.find('.richtext *:empty:not(br)', 'root');
emptyElements.forEach((emptyElement) => {
sa11y.results.push({
element: emptyElement,
type: 'error',
content: 'Bitte entferne leere Absätze um Verwirrung zu vermeiden.',
inline: false,
position: 'beforebegin',
});
});
const allDone = new CustomEvent('sa11y-resume');
document.dispatchEvent(allDone);
});
</script>
<style>
.modx-edit-button {
position: fixed;
left: 15px;
bottom: 15px;
z-index: 9999;
font-size: .75rem;
font-weight: bold;
padding: 11px 20px;
background-color: #f1f1f1;
border-radius: 4px;
opacity: 0.1;
transition: 0.3s;
&:hover {
opacity: 1;
}
}
</style>
<a href="{$_modx->config.manager_url}?a=resource/update&id={$_modx->resource.id}" class="modx-edit-button">✏️</a>
{/if}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment