MODx — a bit improved admin area Evolution

Last 3 days I spent studying Revolution, and decided that my projects are still too early to move her. But I really liked one feature in the admin area, namely: when opening any resource tircik save costs on "Continue editing". That is, you open the resource, edit, save, and you can edit it further.

Personally I find it very convenient as all the chunks and snippets I edit in aminka using EditArea.
But Evolution is necessary when entering into a online flip tircik from "Close" to "Continue", which is very annoying, because EdiatArea able to save the document by Ctrl+S, and if in the heat of the changes I forgot to move Chirchik and pressed, the habit of Ctrl+S — will have to look for that you just edited.

A trifle, but nice. And it's from these little things add up working day and the General mood.

Solution is simple: you need to make a plugin, which for me will be to switch tircik to the desired position.





5 minutes to study the layout of the admin, and the desired item was found is select#stay.
Next trick:
Create a plug-in (object->Plugins->Create a plugin) called it AlwaysStay and copy the code
the
$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
Thank you comrade Andchir for more nice code, I advise you to use it if you don't need jquery.
the
 <script type='text/javascript'>
if(!$('stay').value) $('stay').value=2;
</script>


On the tab "System events" note
OnDocFormRender
OnTempFormRender
OnChunkFormRender
OnSnipFormRender
OnPluginFormRender

Persistent and you're done.

Go to any document or snippet and see that tircik is set to Continue. If it is switched to position "Create new", then it will also remain.
If you want the plugin not working in chunks, for example, disable the corresponding event (OnChunkFormRender).
Article based on information from habrahabr.ru

Комментарии

Популярные сообщения из этого блога

Integration of PostgreSQL with MS SQL Server for those who want faster and deeper

Parse URL in Zend Framework 2

Custom database queries in MODx Revolution