We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38421
    • 10 Posts
    String Output modifiers are great! There is very clear documentation here:
    https://docs.modx.com/revolution/2.x/making-sites-with-modx/customizing-content/input-and-output-filters-(output-modifiers)

    Unfortunately i'm running into an issue / bug where Template Variables that have NOT been given access to Templates are actually returning default value when [[*called]]. For instance I have Two Templates:

    My Car
    My Truck

    I have a TV called CarColor (only access to the Template - My Car) and a TV called TruckColor (only access to the Template - My Truck). I have both TVs set as required & give them default values CarColor="BlueCar" TruckColor="BlueTruck".

    This is where I'm having a problem. I assigned a document to the Template - My Car. The following output modifier is not showing empty:

    [[*TruckColor:notempty=`Found [[*TruckColor]]`]]

    It is returning the default value BlueTruck even though the document does not have access to the My Truck template or it's template variables.

    I conducted a quick test and it appears that every document seems to have access to all TVs that are set to be required & given a default value - EVEN IF THEY DO NOT HAVE ACCESS TO THE TEMPLATE.

    Why can I access these template variables?

    Any guidance is greatly appreciated.

    This question has been answered by Bruno17. See the first response.

    • discuss.answer
      • 4172
      • 5,888 Posts
      Not assigning a TV to a template, doesn't meen, you haven't access to that TV or its default-value in that template.
      It only means, you will not see that TV as a input-TV in the manager.

      The question is, what is your reason to use this TV in your template at all, if not assigned to it? [ed. note: Bruno17 last edited this post 9 years, 1 month ago.]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 38421
        • 10 Posts
        Quote from: Bruno17 at Aug 01, 2017, 10:06 AM
        Not assigning a TV to a template, doesn't meen, you haven't access to that TV or its default-value in that template.
        It only means, you will not see that TV as a input-TV in the manager.

        Hi Bruno

        In my real world example: I call a [[*Schema]] chunk in the header of every page. It looks to see if certain TVs exist to determine what type of page is loading (Product, Blog, etc..) and then loads the appropriate javascript for that schema type. If it finds a TV called ShoppingPrice it knows it's a product page with a price and loads the javascript for the Product Schema.

        I did not realize pages that were not given access to TV's could still access them directly through a [[*TV]] call. I guess my workaround would be to remove the default value assigned to these TVs so that it is empty on pages that should not have access to the TV.

        I did understand I could call snippets (GetResources, Wayfinder) to get access to TV's for different documents but I did not know that a simple TV call [[*TV]] in a Template would go outside of the TVs assigned to the current document.

        Derek