Skip to content

Instantly share code, notes, and snippets.

@matdave
Last active March 5, 2021 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matdave/d519653af99200995a58ab5ce18ea28f to your computer and use it in GitHub Desktop.
Save matdave/d519653af99200995a58ab5ce18ea28f to your computer and use it in GitHub Desktop.
showUrl MODX
<?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