Skip to content

Instantly share code, notes, and snippets.

@pepebe
Created April 15, 2014 13:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pepebe/10730983 to your computer and use it in GitHub Desktop.
Save pepebe/10730983 to your computer and use it in GitHub Desktop.
Hide TVs from root resources in MODX Manager
<?php
/**
* Hide TVs for root elements...
*/
/* Set option(s) here */
$tvs_to_hide = '1,2';
/* ---------------------------------- */
$parentId = $resource->get('parent');
if($parentId == 0){
switch($modx->event->name){
case 'OnDocFormRender':
$html = "
<script type='text/javascript'>
Ext.onReady(function () {
console.log('Parent id is 0 - Hide some TVs from user');
var tvs_to_hide = [".$tvs_to_hide."];
Ext.each(
tvs_to_hide,
function(tv_to_hide, index) {
var tv = Ext.get('tv' + tv_to_hide + '-tr');
if(tv){
console.log('tv' + tv_to_hide + ' found and hidden');
tv.setVisibilityMode(Ext.Element.DISPLAY).hide();
}
else{
console.log('tv' + tv_to_hide + ' cannot be found');
}
}
);
});
</script>
";
$modx->regClientStartupHTMLBlock($html);
break;
default:
break;
}
return;
}
else {
return;
}
/**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment