Created
September 19, 2018 10:22
-
-
Save sebastian-marinescu/744f1f9885311ea74fc87fd33b84e7a0 to your computer and use it in GitHub Desktop.
PHP snippet for MODX, that is used as a plugin to sort the resource-tabs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment