We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29774
    • 386 Posts
    Related is a snippet for creating one-to-many and many-to-many relationships between MODx documents in the manager. You basically use it to generate dynamic select menus and checkboxes. It does more than is possible with @SELECT or even @EVAL return $modx->runSnippet(’Ditto’...). For example, you can use ’ultimateParent’ as the value for either the parents parameter or as a tag value to match, and you can specify that child documents inherit their parent’s relationship.

    This beta version suports matching documents by one or more tags (tvs), each with one or more values, eg:
    @EVAL return $modx->runSnippet('Related', array("parents"=>"40,24","tags"=>"myTV:value1|value2|value3,anotherTV:value1|value2","inherit"=>"1","noneOption"=>"1"));
    


    I’d appreciate it if people could check it out and do some real world testing.

    Also, a few questions:

    * should I introduce some AND, OR, NOT style logic to the tag matching?
    * should I strip all duplicates, say when the same document matches two tags?

    Finally, I’m considering extending this snippet to provide a way to generate dynamic form filters on the front end too - allowing the creation of advanced search forms - essentially a different take on what tvExplorer already does. Is it worth me doing this?

    Many thanks

    Mark
      Snippets: GoogleMap | FileDetails | Related Plugin: SSL
      • 4749
      • 623 Posts
      Yes! If you are already in the process, by all means, keep going. This is a wonderful snippet that I wanted to use a while back, but haven’t had a need yet. However, that need may come sooner rather than later. Thanks for the work!
        The MODx has you...
        Utah Web Design
        • 29774
        • 386 Posts
        Hey cbaone

        Since I wrote this post Urique released a snippet called Quill which you may want to look at - it can generate form fields on the front end as well as in the Manager, and allows you to create relationships much like Related (except it doesn’t do tagging). I may get a chance to revisit Related in a month or so and will consider where to go with it at that point.

        Cheers

        Mark
          Snippets: GoogleMap | FileDetails | Related Plugin: SSL