Show TV only on some Resources

I have a TV which is applied to a Template.

I want to hide this TV in the Manager for all Resources that use that Template - except for one.

Is this possible?

I have a Form Customisation rule which hides the TV for the template.

I tried adding a second rule for that template - constrained to the ID of the Resource I want to show it on - and instructing that to show the TV.

This seems to have no effect.

Even if it’s added to a second Form Customisation Set.

Any ideas gratefully received!

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.

$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':
            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>');
1 Like

maybe two different static templates, with different TV sets which point to the same static file?

1 Like

Thanks @halftrainedharry - I’ll take a look at this.

Thanks @bruno17 - I’d normally just create a new template based on the original for an issue like this - but this site is quite well established and quite a few functions already exist which rely on all of the resources using this template. I may still have to investigate this route further!

@dejaya maybe you can give this a try:

  • one Form Customisation rule for all resources: move TV in custom tab and hide this tab
  • another Form Customisation rule for one resource: show custom tab or try to move tv to a different position

Does this work? :thinking: