In element tab, scroll way down ...find plugins header
click the little plus sign on the plugins header to create a new plugin
observe three tabs on new plugin page
on first tab Create/Edit Plugin, give desired name: rearrangeMYtabs
in Plugin code (php): textarea, paste the code exactly as it is - in previous post
on second tab System Events, CTRL+F on browser to find this event: OnBeforeManagerPageInit
click the corresponding checkbox on OnBeforeManagerPageInit event
Active/Enabled Plugins fire each time MODX Manager is requested.
The plugin can be set to fire at precise times and only at those times.
In this case, it will fire just before a manager page initializes - gives your plugin ample chance to actually do its JavaScript work - of rearranging
TinymceWrapper: Complete back/frontend content solution. Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!) 5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
This plugin might crash though, for resources that DO NOT have a TV attached to them via their template
TinymceWrapper: Complete back/frontend content solution. Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!) 5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
I just had this problem. On resource/create I just show 2 Tabs via the FC. So the script broke and I saw an empty resource-form.
The fix for me in @bezumkin's code is to check if the tabs we want to push back to MODx.tabs are not null:
<?php
switch ($modx->event->name) {
case 'OnBeforeManagerPageInit':
$modx->controller->addHtml('
<script>
Ext.ComponentMgr.onAvailable("modx-resource-tabs", function() {
// Order of tabs
var tabs = {
"modx-resource-settings": null,
"modx-panel-resource-tv": null,
"modx-page-settings": null,
"modx-resource-access-permissions": null,
};
var i, item, id;
for (i in this.items) {
if (this.items.hasOwnProperty(i)) {
item = this.items[i];
id = item["id"];
// TV tab has no id for some reason
if (id == undefined && item["xtype"] == "modx-panel-resource-tv") {
id = "modx-panel-resource-tv";
}
tabs[id] = item;
}
}
this.items = [];
for (i in tabs) {
if (tabs.hasOwnProperty(i) && tabs[i] !== null) {
this.items.push(tabs[i]);
}
}
});
</script>
');
break;
}
In this context I only miss (when saving a resource) the cursor to stay in that field where it has been right before saving a resource and if possible right at that position in the field the cursor exactly has been (I am not sure but I think this works by default if you don´t use this Plugin).
Do you think this is also possible using Javascript?
[ed. note: lettis last edited this post 8 years, 2 months ago.]
For anybody else looking to also order tabs from extras, like lets say Sterc's SeoTab: I had to listen to a component being available much later and then change it so it removes and re-adds the tabs, then updates. This is my currently working code:
<?php
switch ($modx->event->name) {
case 'OnBeforeManagerPageInit':
$modx->controller->addHtml('
<script>
// This should be a component that registers late
Ext.ComponentMgr.onAvailable("emptifier", function(){
// Order of tabs
var tabs = {
"collections-category-resources": null,
"modx-resource-settings": null,
"modx-panel-resource-tv": null,
"seo-tab": null,
"modx-page-settings": null,
"modx-resource-access-permissions": null,
"versionx-resource-tab": null
};
// Get completely loaded tabs
var modxTabs = Ext.getCmp("modx-resource-tabs");
if (!modxTabs) {
return;
}
var i, item, id;
for (i in modxTabs.items.items) {
if (modxTabs.items.items.hasOwnProperty(i)) {
item = modxTabs.items.items[i];
id = item["id"];
// TV tab has no id for some reason
if (id == undefined && item["xtype"] == "modx-panel-resource-tv") {
id = "modx-panel-resource-tv";
}
tabs[id] = item;
}
}
for (i in tabs) {
if (tabs.hasOwnProperty(i) && tabs[i] !== null) {
modxTabs.remove(tabs[i], false);
modxTabs.add(tabs[i]);
}
}
modxTabs.update();
});
</script>
');
break;
}
[ed. note: sebastian-marinescu last edited this post 5 years, 7 months ago.]