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

    I would like to populate a TV using the method described here. So far, so good. Works great! Very Cool!

    Now, I would like the value in the TV to remain empty until an editor selects a value from the pull down list. Right now it assigns the first item on the list.

    How can I do this?

    http://modxcms.com/forums/index.php?%3Btopic=26158.0

    Quote from: therebechips at Jun 04, 2008, 05:46 AM

    Hi there,

    what you need to do is create a new multi-select list (or checkbox) TV for your article template, and dynamically populate that with your list of products. In the TV setup specify the Widget to be a delimited list with a comma as the delimiter. The input option values would be a Ditto call, something like this:
    @EVAL return substr($modx->runSnippet('Ditto', array("parents"=>"4","depth"=>"1","display"=>"all","showInMenuOnly"=>"0","sortBy"=>"pagetitle","sortDir"=>"ASC", "tpl"=>"@CODE ||[+pagetitle+]==[+id+]")), 2);
    


    Now you can create a relationship between an article and one or more products. On the product page you can then use Ditto with the tags parameter to output the most recent articles that are tagged with the current page id.
      www.terrybarthdesign.com
      • 29525
      • 388 Posts
      Best I’ve come up with so far is to create an additional document that ditto reads in with a page title that says "Select one of these".

        www.terrybarthdesign.com
        • 29525
        • 388 Posts

        While, I’m still looking for answer to my question about populating the default value with a blank rather than the first value generated by the code, I have an new question.

        Is there a way for a child document to inherit the value from the parent using this code? I tried using @INHERIT in the default value, but this didn’t work. I suspect its because the on the child documents the field is already populated with the first value and therefore overriding the @INHERIT.

        Any thoughts?
          www.terrybarthdesign.com
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: Terry at May 02, 2009, 05:35 PM

          Is there a way for a child document to inherit the value from the parent using this code? I tried using @INHERIT in the default value, but this didn’t work. I suspect its because the on the child documents the field is already populated with the first value and therefore overriding the @INHERIT.

          Any thoughts?
          Unfortunately, @INHERIT in MODx 0.9.6.x always uses the id of the page processing the TV, so it will not properly inherit values inside of Ditto. This is solved in Revolution, but is troublesome to fix in the Evolution branch.

          I’ll have to leave the other question unanswered, as I am not familiar with that technique with Ditto.
            • 29525
            • 388 Posts

            Thanks guys, I’ll take a swing this.
              www.terrybarthdesign.com