We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23571
    • 223 Posts
    Okay, I am using the code below in a list-box template variable. It allows me to populate a list of choices from the contents of a directory (in this case personnel) and then display the results via the TV. This portion works just fine.

    Where the problem is: when one of the TV values are changed in the directory driving the Ditto choices then the list choice must be reselected the next time the document owning the TV is saved, otherwise the document is saved with nothing selected.

    Does anyone know how to address this?

    @EVAL return substr($modx->runSnippet('Ditto', array('startID' => '7','tpl'=>'@CODE ||[+title+]==<dl><dd><img src="[+personnelImage+]" alt="[+title+]" width="78" height="100" /></dd><dt><b>[+title+]</b>[+personnelPhone:isnot=``:then=`[+personnelPhone+]`+]<br />[+personnelEmail:isnot=``:then=`<a href="mailto:[+personnelEmail+]" title="[+personnelEmail+]" border="0">[+personnelEmail+]</a>`+]</dt></dl><div style="clear:both;"></div>','sortDir'=>'asc','filter'=>'id,54,2')), 2);
      • 5340
      • 1,624 Posts
      I’m not sure what you are doing but you should not use values as a reference. You should use IDs that are related to name you are using.

      Have a look at this article. It might help
        • 23571
        • 223 Posts
        So, would a better approach be to use something like @DIRECTORY?
          • 5340
          • 1,624 Posts
          I fail to understand what you are trying to do.

          Maybe you can post your folder structure.
          Would be nice to see an image of how your TV looks like when you edit a document.

            • 23571
            • 223 Posts
            Yeah, it is hard to fully explain. I think we pinpointed the issue. I will post here when the solution is completed.
              • 23571
              • 223 Posts
              The explanation is kind of long, so I posted it fully on my blog. We created a new snippet that allows you to reach out to any document within your MODx site and retrieve any placeholder and/or any Template Variable (TV) and then structure the output using a TPL chunk.

              We looked around and figured that this probably already existed, but couldn’t locate anything.

              Here is the link: http://www.gregorysmart.com/2009/09/18/new-docdata-snippet/
                • 4971
                • 964 Posts
                Greg, thanks for sharing!

                Could you explain the Eval code?

                @EVAL return substr($modx->runSnippet('Ditto', array('startID' => '7','tpl'=>'@CODE ||[+title+]==[+id+]','sortDir'=>'asc')), 2)


                I understand must of it except the @CODE part, what does @CODE do?

                Why substr returns from 2?

                  Website: www.mercologia.com
                  MODX Revo Tutorials:  www.modxperience.com

                  MODX Professional Partner
                  • 23571
                  • 223 Posts
                  That was unintentional. It is unnecessary in this instance. It has been corrected. Thanks for catching that!
                    • 4971
                    • 964 Posts
                    aaahh OK... any pointers in the @CODE?
                    I have not been able to find any info anywhere...
                      Website: www.mercologia.com
                      MODX Revo Tutorials:  www.modxperience.com

                      MODX Professional Partner
                      • 23571
                      • 223 Posts
                      We noticed that when DocData is used with Ditto in a multi-list select the snippet didn’t function properly. That has now been addressed with a .2 version (download: http://www.gregorysmart.com/2009/09/18/new-docdata-snippet/). It allows you to introduce a delimiter widget to create a comma-separated list and the snippet will now function appropriately in that scenario.