We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15083
    • 697 Posts
    Hi there,

    I have a piece of content that I want the user to be able to change. In fact there are 5 values the user may need to change. So I just added 5 TV’s. the problem is that this content is persistent across the entire site, so if they update just the homepage then it will not be aplied to the sub pages.

    Am I correct in thinking that the @INHERIT binding will only apply to the children of a page? So in my case it will not work as the homepage has no children?

    If I use a chunk then the user will have to go into the chunk section to change the data....and I dont want to allow them to do that as <code> will scare them off?

    Is there another way of doing the above that will make changing the data easy for an editor?

    thanks in advance!!!!
      • 25663 MODX Staff
      • 12,272 Posts
      A good solution might be to use a combination of chunks, a TV and the @INHERIT binding.

      Quick idea:
      Make the 5 options values in 5 different chunks ("option1", "option2", "option3", etc.).

      Create a new TV with a drop-down list widget: [*optionalValues*]

      Make sure to assign this TV to every template that needs access to those options.

      For input options, enter something along the lines of the following, filling in all the "options" and making your own value/chunk names that actually makes sense. This is not an output widget by the way and the text field entry may be a bit short, FYI. I tend to write these in a text editor then copy/paste them into the small text input field myself.
      Value 1=={{option1}}||Value 2=={{option 2}}||Value 3=={{option3}} ... 

      In the code above the key/value delimeter is a double-equal-sign and the option/row delimeter is a double-pipe character. On US keyboards that’s the shifted value of the backslash key, and on my keyboard immediately above the main return/enter key. You are not restricted to using chunks for the value either, but it might make ongoing maintenance a bit easier.

      For the default value, enter:
      @INHERIT {{option1}}


      How this works:
      First, if they don’t choose something, they’ll always get the chunk values in the "option1" chunk.

      Next if they do choose something, everything in that "section" (assuming the page is a container-document with children) will inherit the value chosen at the partent. Of course you could change this within the child-documents as well.

      On those pages below the [*content*] area you should see a pop-up list with the values that are simple to change from page to page, or section to section.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 15083
        • 697 Posts
        thanks for the quick reply ryan.

        I think that will probably take longer than showing the user how to edit 5 chunks, I can lock the rest to prevent disaster!!!!
        Is there any scope for a "Master TV", and all templates that use it will take its value, but the user can change it in any page that uses the templates?

        I think this is one of them "Is there a tool that does everything I want it to do just for this job" questions!!

        Thanks a lot smiley
          • 25663 MODX Staff
          • 12,272 Posts
          You’d want the default value filled out for the TV and it’d do exactly what you want, assuming it was assigned to each template. That way when you create a new page it automatically is assigned a value, but you can still go in and edit the value.

          The benefit of setting up the drop-down list widget is that it’s incredibly easy and bullet proof for client self-administration. It’s also likely much faster for them to use, but takes a few extra minutes to set up on the developer end.
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me