⬆️ ⬇️

MODx - slightly improve the Evolution admin panel

I spent the last 3 days studying Revolution, and decided that it was too early to translate my projects into it. But I really liked one feature in the admin panel there, namely: when opening any resource, the save tyr stands on “Continue editing”. That is, you open a resource, edit it, save it and you can edit it further.



Personally, this is very convenient for me, since I edit all the chunks and snippets in the amine using EditArea.

But in Evolution you need to rearrange the tyrchik from “Close” to “Continue” when entering the resource, which is very annoying, because EdiatArea can save the document by Ctrl + S, and if in the heat of changes I forgot to rearrange the tyrchik and clicked, by habit Ctrl + S will have to look for what you just edited.



Trifle, but not nice. And from such trifles there is a working day and mood in general.

')

The solution is simple: you need to make a plugin that will switch the tyrchik to the desired position for me.











5 minutes to study the layout of the admin panel, and the desired item is found - this is select # stay.

Next thing is the technique:

Create a plugin (Manage Elements-> Plugins-> Create Plugin), call it AlwaysStay and copy the code

$e = & $modx->Event; if ($e->name == "OnDocFormRender" || $e->name == "OnTempFormRender" || $e->name == "OnChunkFormRender" || $e->name == "OnSnipFormRender" || $e->name == "OnPluginFormRender" ) { $html = " <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js' type='text/javascript'></script> <script type='text/javascript'> var j = jQuery.noConflict(); j(document).ready(function() { if (j('#stay #stay3').attr('selected') == true) { j('#stay #stay2').attr('selected', true) }; }) </script> "; $e->output($html); } 


Updated

Thanks comrade Andchir for a more pleasant code, I advise you to use it if you do not need jquery.

  <script type='text/javascript'> if(!$('stay').value) $('stay').value=2; </script> 




On the "System Events" tab, we note

OnDocFormRender

OnTempFormRender

OnChunkFormRender

OnSnipFormRender

OnPluginFormRender



We save and everything is ready.



We go into any document or snippet and see that the tyrchik is in the “Continue” position. If you rearrange it to the “Create a new” position, then it will also remain.

If you want the plugin to not work on chunks, for example, disable the corresponding event (OnChunkFormRender).

Source: https://habr.com/ru/post/112813/



All Articles