We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21246
    • 55 Posts
    I came across an issue with a TV ’s default set to @INHERIT and assigning @DOCUMENT binding to the TV. The DOCUMENT binding works only on the document I edited. The CHILDREN do not inherit the value of the @DOCUMENT binding. Is this a bug or a feature?

    I am attempting to have a TV in a template that pulls content from a referenced doc. With inherit I could assign the values down the tree and override them on any individual document. I prefer not to use a chunk since that creates a DB entry that I can’t easily change without modifying the value of that TV in the document.

    Any suggestions for a work around or fix?

    MODx Version 0.9.6.3
      • 21246
      • 55 Posts
      I have resolved this by implementing another snippet called from the TV. Here is some more info in case you have the same issue and could benefit from what worked for me.

      The code that controls this behavior is:

      [modx install dir]/includes/tmplvars.commands.inc.php

      within the case statement beginning on line 63 for @INHERIT there is an IF on line 76;

       if ((string) $tv['value'] !== '' && $tv['value'] { 0 }
                              != '@') {
                              $output = (string) $tv['value'];
                              break 2;                    
      
      
      


      I did not want to hack the core which is something to avoid at all costs.I searched for another way to accomplish what I wanted.

      GetField snippet to the rescue!

      I leveraged the GetField snippet and set its value to call the document ID I wanted and set the field to content. The snippet call is inherited on the children pages where it is set in the parent and works perfect. Now I can set up some documents that hold content I want to reuse on different documents and change the order of it (like ads or banners etc.. ) as I need to without messing with a template. Any page can call any documents content by setting this value. Perfect.

      As with seemingly everything in MODx there are many ways to accomplish what you want. So flexible. I am busy replacing multiple Drupal installs after repeated problems with security patching and module upgrades that broke functionality with no references in the docs. To many hands in the kitchen! MODx rocks. Kudos to the team and thanks for your hard work.