I really like this plugin, and I wanted it to be global whenevr I edit anything in MODx so I tweaked the code and now it’s working nice.
I’m pretty novice when it comes to programing and I’m pretty sure there is a better, neater K.I.S.S way to add
OR in
case: situations like this. if anyone see’s a better way to code it please drop some text.
anyway, this is the code I got now in the plugin.
you’ll also need to check some boxes in
System Events, in my case it was: OnChunkFormRender, OnDocFormRender, OnModFormRender, OnPluginFormRender, OnSnipFormRender, OnTVFormRender, OnTempFormRender.
$e = & $modx->Event;
switch ($e->name) {
case "OnDocFormRender":
$html = '<div class="subTitle" style="position:absolute; top:0px; left:0px; width:100%; z-index:30; position:fixed;">
<span class="right"><img src="media/images/_tx_.gif" width="1" height="5"><br />Create/ edit document</span>
<table cellpadding="0" cellspacing="0">
<tr>
<td id="Button1" onclick="documentDirty=false; document.mutate.save.click();"><img src="media/images/icons/save.gif" align="absmiddle"> Save</td>
<script>createButton(document.getElementById("Button1"));</script>
<td id="Button2" onclick="deletedocument();"><img src="media/images/icons/delete.gif" align="absmiddle"> Delete</span></td>
<script>createButton(document.getElementById("Button2"));</script>
<td id="Button5" onclick="'."document.location.href='index.php?a=3&id=79'".';"><img src="media/images/icons/cancel.gif" align="absmiddle"> Cancel</td>
<script>createButton(document.getElementById("Button5"));</script>
</tr>
</table>
<div class="subTitle">
<table border="0" cellspacing="1" cellpadding="1">
<tr>
<td><span class="comment"> After saving:</span></td>
<td><input name="stay" type="radio" class="inputBox" value="1" /></td><td><span class="comment">Add another</span></td>
<td><input name="stay" type="radio" class="inputBox" value="2" /></td><td><span class="comment">Continue editing</span></td>
<td><input name="stay" type="radio" class="inputBox" value="" checked='."'checked'".' /></td><td><span class="comment">Close</span></td>
</tr>
</table>
</div>
</div>';
$e->output($html);
// show also when creating Chunks
case "OnChunkFormRender":
$html = '<div class="subTitle" style="position:absolute; top:0px; left:0px; width:100%; z-index:30; position:fixed;">
<span class="right"><img src="media/images/_tx_.gif" width="1" height="5"><br />Create/ edit document</span>
<table cellpadding="0" cellspacing="0">
<tr>
<td id="Button1" onclick="documentDirty=false; document.mutate.save.click();"><img src="media/images/icons/save.gif" align="absmiddle"> Save</td>
<script>createButton(document.getElementById("Button1"));</script>
<td id="Button2" onclick="deletedocument();"><img src="media/images/icons/delete.gif" align="absmiddle"> Delete</span></td>
<script>createButton(document.getElementById("Button2"));</script>
<td id="Button5" onclick="'."document.location.href='index.php?a=3&id=79'".';"><img src="media/images/icons/cancel.gif" align="absmiddle"> Cancel</td>
<script>createButton(document.getElementById("Button5"));</script>
</tr>
</table>
<div class="subTitle">
<table border="0" cellspacing="1" cellpadding="1">
<tr>
<td><span class="comment"> After saving:</span></td>
<td><input name="stay" type="radio" class="inputBox" value="1" /></td><td><span class="comment">Add another</span></td>
<td><input name="stay" type="radio" class="inputBox" value="2" /></td><td><span class="comment">Continue editing</span></td>
<td><input name="stay" type="radio" class="inputBox" value="" checked='."'checked'".' /></td><td><span class="comment">Close</span></td>
</tr>
</table>
</div>
</div>';
$e->output($html);
// show also when creating Modules
case "OnModFormRender":
$html = '<div class="subTitle" style="position:absolute; top:0px; left:0px; width:100%; z-index:30; position:fixed;">
<span class="right"><img src="media/images/_tx_.gif" width="1" height="5"><br />Create/ edit document</span>
<table cellpadding="0" cellspacing="0">
<tr>
<td id="Button1" onclick="documentDirty=false; document.mutate.save.click();"><img src="media/images/icons/save.gif" align="absmiddle"> Save</td>
<script>createButton(document.getElementById("Button1"));</script>
<td id="Button2" onclick="deletedocument();"><img src="media/images/icons/delete.gif" align="absmiddle"> Delete</span></td>
<script>createButton(document.getElementById("Button2"));</script>
<td id="Button5" onclick="'."document.location.href='index.php?a=3&id=79'".';"><img src="media/images/icons/cancel.gif" align="absmiddle"> Cancel</td>
<script>createButton(document.getElementById("Button5"));</script>
</tr>
</table>
<div class="subTitle">
<table border="0" cellspacing="1" cellpadding="1">
<tr>
<td><span class="comment"> After saving:</span></td>
<td><input name="stay" type="radio" class="inputBox" value="1" /></td><td><span class="comment">Add another</span></td>
<td><input name="stay" type="radio" class="inputBox" value="2" /></td><td><span class="comment">Continue editing</span></td>
<td><input name="stay" type="radio" class="inputBox" value="" checked='."'checked'".' /></td><td><span class="comment">Close</span></td>
</tr>
</table>
</div>
</div>';
$e->output($html);
// show also when creating Plugins
case "OnPluginFormRender":
$html = '<div class="subTitle" style="position:absolute; top:0px; left:0px; width:100%; z-index:30; position:fixed;">
<span class="right"><img src="media/images/_tx_.gif" width="1" height="5"><br />Create/ edit document</span>
<table cellpadding="0" cellspacing="0">
<tr>
<td id="Button1" onclick="documentDirty=false; document.mutate.save.click();"><img src="media/images/icons/save.gif" align="absmiddle"> Save</td>
<script>createButton(document.getElementById("Button1"));</script>
<td id="Button2" onclick="deletedocument();"><img src="media/images/icons/delete.gif" align="absmiddle"> Delete</span></td>
<script>createButton(document.getElementById("Button2"));</script>
<td id="Button5" onclick="'."document.location.href='index.php?a=3&id=79'".';"><img src="media/images/icons/cancel.gif" align="absmiddle"> Cancel</td>
<script>createButton(document.getElementById("Button5"));</script>
</tr>
</table>
<div class="subTitle">
<table border="0" cellspacing="1" cellpadding="1">
<tr>
<td><span class="comment"> After saving:</span></td>
<td><input name="stay" type="radio" class="inputBox" value="1" /></td><td><span class="comment">Add another</span></td>
<td><input name="stay" type="radio" class="inputBox" value="2" /></td><td><span class="comment">Continue editing</span></td>
<td><input name="stay" type="radio" class="inputBox" value="" checked='."'checked'".' /></td><td><span class="comment">Close</span></td>
</tr>
</table>
</div>
</div>';
$e->output($html);
// show also when creating Snippets
case "OnSnipFormRender":
$html = '<div class="subTitle" style="position:absolute; top:0px; left:0px; width:100%; z-index:30; position:fixed;">
<span class="right"><img src="media/images/_tx_.gif" width="1" height="5"><br />Create/ edit document</span>
<table cellpadding="0" cellspacing="0">
<tr>
<td id="Button1" onclick="documentDirty=false; document.mutate.save.click();"><img src="media/images/icons/save.gif" align="absmiddle"> Save</td>
<script>createButton(document.getElementById("Button1"));</script>
<td id="Button2" onclick="deletedocument();"><img src="media/images/icons/delete.gif" align="absmiddle"> Delete</span></td>
<script>createButton(document.getElementById("Button2"));</script>
<td id="Button5" onclick="'."document.location.href='index.php?a=3&id=79'".';"><img src="media/images/icons/cancel.gif" align="absmiddle"> Cancel</td>
<script>createButton(document.getElementById("Button5"));</script>
</tr>
</table>
<div class="subTitle">
<table border="0" cellspacing="1" cellpadding="1">
<tr>
<td><span class="comment"> After saving:</span></td>
<td><input name="stay" type="radio" class="inputBox" value="1" /></td><td><span class="comment">Add another</span></td>
<td><input name="stay" type="radio" class="inputBox" value="2" /></td><td><span class="comment">Continue editing</span></td>
<td><input name="stay" type="radio" class="inputBox" value="" checked='."'checked'".' /></td><td><span class="comment">Close</span></td>
</tr>
</table>
</div>
</div>';
$e->output($html);
// show also when creating TVs
case "OnTVFormRender":
$html = '<div class="subTitle" style="position:absolute; top:0px; left:0px; width:100%; z-index:30; position:fixed;">
<span class="right"><img src="media/images/_tx_.gif" width="1" height="5"><br />Create/ edit document</span>
<table cellpadding="0" cellspacing="0">
<tr>
<td id="Button1" onclick="documentDirty=false; document.mutate.save.click();"><img src="media/images/icons/save.gif" align="absmiddle"> Save</td>
<script>createButton(document.getElementById("Button1"));</script>
<td id="Button2" onclick="deletedocument();"><img src="media/images/icons/delete.gif" align="absmiddle"> Delete</span></td>
<script>createButton(document.getElementById("Button2"));</script>
<td id="Button5" onclick="'."document.location.href='index.php?a=3&id=79'".';"><img src="media/images/icons/cancel.gif" align="absmiddle"> Cancel</td>
<script>createButton(document.getElementById("Button5"));</script>
</tr>
</table>
<div class="subTitle">
<table border="0" cellspacing="1" cellpadding="1">
<tr>
<td><span class="comment"> After saving:</span></td>
<td><input name="stay" type="radio" class="inputBox" value="1" /></td><td><span class="comment">Add another</span></td>
<td><input name="stay" type="radio" class="inputBox" value="2" /></td><td><span class="comment">Continue editing</span></td>
<td><input name="stay" type="radio" class="inputBox" value="" checked='."'checked'".' /></td><td><span class="comment">Close</span></td>
</tr>
</table>
</div>
</div>';
$e->output($html);
// show also when creating Templates
case "OnTempFormRender":
$html = '<div class="subTitle" style="position:absolute; top:0px; left:0px; width:100%; z-index:30; position:fixed;">
<span class="right"><img src="media/images/_tx_.gif" width="1" height="5"><br />Create/ edit document</span>
<table cellpadding="0" cellspacing="0">
<tr>
<td id="Button1" onclick="documentDirty=false; document.mutate.save.click();"><img src="media/images/icons/save.gif" align="absmiddle"> Save</td>
<script>createButton(document.getElementById("Button1"));</script>
<td id="Button2" onclick="deletedocument();"><img src="media/images/icons/delete.gif" align="absmiddle"> Delete</span></td>
<script>createButton(document.getElementById("Button2"));</script>
<td id="Button5" onclick="'."document.location.href='index.php?a=3&id=79'".';"><img src="media/images/icons/cancel.gif" align="absmiddle"> Cancel</td>
<script>createButton(document.getElementById("Button5"));</script>
</tr>
</table>
<div class="subTitle">
<table border="0" cellspacing="1" cellpadding="1">
<tr>
<td><span class="comment"> After saving:</span></td>
<td><input name="stay" type="radio" class="inputBox" value="1" /></td><td><span class="comment">Add another</span></td>
<td><input name="stay" type="radio" class="inputBox" value="2" /></td><td><span class="comment">Continue editing</span></td>
<td><input name="stay" type="radio" class="inputBox" value="" checked='."'checked'".' /></td><td><span class="comment">Close</span></td>
</tr>
</table>
</div>
</div>';
$e->output($html);
}