We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27442
    • 103 Posts
    I can’t seem to get the @INHERIT binding working the way that I want. Perhaps it’s because of the way that I’m trying to use it. I’m fairly certain that I had something like this working in the past, but can’t seem to get it now. I’d appreciate any insight.

    I have a TV named [*notification*] which is used to post informational notices. The input type is a dropdown list menu (I’ve also tried radio buttons, so that’s not the problem). The output widget is Floater. The input option values are:
    None== ||Summer Shutdown==@DOCUMENT 52||Winter Shutdown==@DOCUMENT 53||Trade Show==@DOCUMENT 55||Inherit from parent doc==@INHERIT


    If I set the TV to any of the @DOCUMENT items or the ’None’ in any resouce, it works as expected always. My intent is to only need to typically change this TV in the upper level resouces and have the lower levels inherit whatever is set for its parent. However, setting the child level resouces to the Inherit setting seems to not work - the TV that I expect to have the inherited value seems to instead have nothing. Is there a reason that I can not use the @INHERIT binding this way?
      • 5532
      • 251 Posts
      Hi There,

      During my travels researching the @Document binding, I could’ve sworn I saw a post that said @Inherit will only work for a new document - existing documents won’t pick up the inheritance (which I thought kind of defeated the purpose). Some of the posts I was reading went WAY back, so this could’ve been changed in Evo etc.

      but this inheritance seems to occur ONLY when the page is first created
      From the Modx Wiki here: http://wiki.modxcms.com/index.php/@INHERIT_Binding

      I hope I’m wrong though!
        • 3749
        • 24,544 Posts
        Quote from: sjh_vt at Feb 21, 2010, 11:32 AM

        The input option values are:
        None== ||Summer Shutdown==@DOCUMENT 52||Winter Shutdown==@DOCUMENT 53||Trade Show==@DOCUMENT 55||Inherit from parent doc==@INHERIT


        First, I think the first value might work as
        None==''||


        Second, I’m not sure if what you’re trying to do will work, although it should. Check this: If no ancestor has the value set or if all ancestors have it set to @INHERIT and there is no default value, you will see no output where the TV resource tag is placed.
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 26931
          • 2,314 Posts
          *bit off topic*
          First, I think the first value might work as None==’’.
          is this best practice?: None==’’.||
          any problems i could run into with this?: None== ||
            • 3749
            • 24,544 Posts
            Quote from: sharkbait at Feb 21, 2010, 03:47 PM

            *bit off topic*
            First, I think the first value might work as None==’’.
            is this best practice?: None==’’.||
            any problems i could run into with this?: None== ||

            TBH, I’ve never tried either one, but I’m not sure what the parser would do with None==|| and the OP seems to be having trouble with it.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 26931
              • 2,314 Posts
              None== || just leaves the value empty
              ...so None==’’.|| is the way to go then? smiley
                • 3749
                • 24,544 Posts
                Quote from: sharkbait at Feb 21, 2010, 03:55 PM

                None== || just leaves the value empty
                ...so None==’’.|| is the way to go then? smiley

                I think so (but without the period):

                None==''||Other Choice==Something else
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 26931
                  • 2,314 Posts
                  I think so (but without the period)
                  thanks
                    • 27442
                    • 103 Posts
                    None== ||
                    works fine for my needs as long as the trailing space is there. The TV is a single space character which ends up floating with the floater widget. More on this behavior below.

                    In an interesting turn of events, as I double checked the behavior of the space character (mentioned above), I added another bogus option that just contained text.
                    None== ||Summer Shutdown==@DOCUMENT 52||Winter Shutdown==@DOCUMENT 53||Trade Show==@DOCUMENT 55||Inherit from parent doc==@INHERIT||Another Test==Some basic text

                    When using only text this way, child resources inherit it as expected!. So essentially, it is working the way that I expect, but not when evaluating @DOCUMENTs. The @DOCUMENT TV’s work fine when set manually, but not when inherited. Could this have something to do with the order of evaluation built into the core?
                      • 3749
                      • 24,544 Posts
                      Quote from: sjh_vt at Feb 21, 2010, 06:25 PM

                      Could this have something to do with the order of evaluation built into the core?
                      Very likely. You might need a custom snippet that would evaluate the TV in the current document, search the parents (if necessary), retrieve the appropriate content, and return the output.

                      Basically, you’d check the raw value in the current document and return the processed value if it’s not @INHERIT. If it is @INHERIT, you’d walk up the parent tree (see the UltimateParent snippet), getting the raw content of the TV from each one and returning the processed output when the content doesn’t = @INHERIT.

                      It’s an interesting problem and it seems to me that there should be a simpler solution, but I haven’t been able to think of one.
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting