pepebe
7/8/2015 - 10:42 PM

hide some tvs for certain resources

hide some tvs for certain resources

<?php
/* trigger onDocFormRender */

$resIds = array(12); /* In welchen Resourcen soll das plugin laufen */
$tvIds = array(1,3); /* Welche TVS sollen dort ausgeblendet werden */

$id = $resource->get('id');
$tvIds = implode(',',$tvIds);

if(!in_array($id, $resIds)) {
    return;
}
else {
    $js = "
            Ext.onReady(function () {
                console.log('hideTVs: ' + '".$tvIds."');
                
                var tvIds = '".$tvIds."'.split(',');
                console.log(tvIds);
                
                tvIds.map( function(tvId) {

                    selector = '#tv' + tvId + '-tr';
                    console.log('hide: ' + selector);
                    
                    var tv = Ext.select(selector);
                    tv.setVisibilityMode(Ext.Element.DISPLAY);
                    tv.hide();
                });
    
            });
    ";
    
    $modx->regClientStartupHTMLBlock('<script>'.$js.'</script>');
    return;
}