Show TV only on some Resources

Yes, that doesn’t seem to work.

If there is a matching rule that hides the TV, then there isn’t a way to make the same TV visible again.


Maybe you could conditionally add some JS code in a plugin that hides the TV.

Something like this may work, but it’s a bit ugly.

<?php
$resource_id_tv_visible = 76; //resource id where the TV should be visible
$html_tag_id = 'tv12-tr'; //ID of the html tag to hide
$eventName = $modx->event->name;
switch($eventName) {
    case 'OnManagerPageBeforeRender':
        switch($scriptProperties['controller']->config['controller']){
            case 'resource/create':
            case 'resource/update':
                if ($scriptProperties['controller']->scriptProperties['id'] != $resource_id_tv_visible){
                    $modx->controller->addHtml('<script>Ext.onReady(function() { Ext.get("' . $html_tag_id . '").hide(); });</script>');
                }
                break;
        }
        break;
}
1 Like