modxcms / revolution

MODX Revolution - Content Management Framework
https://modx.com/
GNU General Public License v2.0
1.36k stars 528 forks source link

Disable a Template Variable #15770

Open jmacdonald-spectacle opened 3 years ago

jmacdonald-spectacle commented 3 years ago

Feature request

Summary

Add the ability to disable a Template Variable

Why is it needed?

Sometimes a TV isn't currently necessary: either for testing or there is a problem with processing. In a complex site, disabling the TV for each template is time-consuming and, if the templates must be re-enabled, error-prone. Disabling through Manager Customization is time-consuming for the same reasons.

Suggested solution(s)

I'd like to see a checkbox on the 'General Information' tab of a TV. It should be unchecked by default and its label should be 'Inactive' to match the behaviour of Plugins.

Related issue(s)/PR(s)

Not related to anything I know of.

Ruslan-Aleev commented 3 years ago

TV has a template tab where you can turn off TV for templates, there is a filter, sorting, etc. In my opinion, turning off the TV with new checkbox is unnecessary behavior. Because confusion will arise, for example: TV is configured, specified for the template, but does not work, but it turns out that TV needs to be turned on (if someone turned it off before). And if I turned off TV through a new checkbox, how can I turn on TV for some templates? If through the templates tab, then TV will turn on automatically for all templates for which TV was set or what?

jmacdonald-spectacle commented 3 years ago

As I said, complex sites can make turning templates on and off difficult.

The TV would be enabled by default, so I don't see the confusion. Existing functionality would remain. This is a 'master switch.'

JoshuaLuckers commented 3 years ago

I like this feature request and the proposed solution.

Because confusion will arise, for example: TV is configured, specified for the template, but does not work, but it turns out that TV needs to be turned on (if someone turned it off before). And if I turned off TV through a new checkbox, how can I turn on TV for some templates? If through the templates tab, then TV will turn on automatically for all templates for which TV was set or what?

If a plugin is marked as inactive you are still able to select the system events it should listen to. For Template Variables the behavior would be equal.

jmacdonald-spectacle commented 3 years ago

Yes, I propose a checkbox on the General Information tab. Easy to see.

TVs would still be available to select in Template elements as well as Form Customization, they would just be ignored by chunks and snippets.

jmacdonald-spectacle commented 3 years ago

Another use case: I start new projects with a master copy of a website. Being able to disable TVs for certain clients would be helpful.

Jako commented 3 years ago

Some extras like getResources, pdoResources etc. have to be modified after adding this option.

jmacdonald-spectacle commented 3 years ago

@Jako I suppose that's true.

I'm mainly interested in hiding a tv in the Manager. Maybe a label of 'Hidden' or 'Hidden in all templates' would work. This would have the same effect as Manager customization without all the customizing.

mishantrop commented 2 years ago

If a plugin is marked as inactive <...>. For Template Variables the behavior would be equal.

@JoshuaLuckers TV and Plugins have different behavior by nature, there is no need to make an artificial unification.

Let's take the idea to the absolute and do the same with templates, snippets, chunks, system settings, access rights, etc. Sounds weird.

I think, the OP ran into a typical XY problem.

jmacdonald-spectacle commented 2 years ago

@mishantrop, Nobody is trying to unify anything. I merely suggested a mechanism that was already in use.