Last active
March 5, 2021 17:09
-
-
Save matdave/d519653af99200995a58ab5ce18ea28f to your computer and use it in GitHub Desktop.
showUrl MODX
This file contains hidden or 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 | |
/** | |
* Plugin to add a read only "url" field to the document tab | |
* | |
* @var modX $modx | |
* @var array $scriptProperties | |
* | |
* @event OnDocFormPrerender | |
*/ | |
if(!$resource || !$mode || $modx == "new") return; | |
$url = $modx->makeUrl($resource->id, $resource->context_key, '', 'full'); | |
$modx->controller->addHtml(" | |
<script> | |
// We are targeting the left column in the resource tab | |
Ext.ComponentMgr.onAvailable('modx-resource-main-left', function(left) { | |
left.on('beforerender', function() { | |
// page is a reference to the whole form panel | |
var page = Ext.getCmp('modx-panel-resource') | |
// record is a reference to our resource fields | |
,record = page.record | |
; | |
// Add new url filed on | |
left.add({ | |
xtype: 'textfield' | |
,name: 'previewurl' | |
,value: '".$url."' | |
,anchor: '100%' | |
,layout: 'anchor' | |
,fieldLabel: 'URL' | |
,readOnly: true | |
}); | |
}) | |
}); | |
</script>"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment