Created
April 15, 2014 13:06
-
-
Save pepebe/10730983 to your computer and use it in GitHub Desktop.
Hide TVs from root resources in MODX Manager
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 | |
/** | |
* 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