During a loop I retrieve template variable (name: fontpageImage) in this way:
$event->getTVValue('fontpageImage');
This all works fine. However for one of my resources I choose to switch to another template (containing NO template variables). Despite changing template and clearing cache I actually get the value of TV frontpageImage (from my previous choice of template). How come it doesn't fail with an error calling $event->getTVValue('fontpageImage');?
You will always get the result of the template variable as it is still in the database, by switching template all you are doing is telling the system to show / hide the tv's.
If you switch back to the original template and empty the tv's, save and then change back to the new template all should be ok.
Paulp, thank you for a really fast and accurate response. That certainly explains it. Eventhough the current TV idea is pretty global by nature, I think this behaviour is pretty unfortunate since you actually explicitly grant access per template (I can think of some unwanted side effects). Show/hide in resource would be a more suitable name
For 10 years I've been complaining about this. These aren't "template" variables, they have nothing to do with templates. That was just a convenient way to categorize resources to be able to assign the "extended resource fields" to something. I have always thought that resources should have been given categories, as elements were, and the extended resource fields assigned by category, if not by individual resource. The way it works, it leads to a multiplicity of templates that serve no purpose except to control TVs.