We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6094
    • 60 Posts
    I’m in the process of setting up some product pages. I’m trying to determine how to setup a TV for related products. This wold be a many to one relationship. So product #1 would have several related products. I would like to be able to use check boxes or maybe a multi select listbox. Has anyone done this before or what is the best way to set something like this up?

    Thanks.
      • 2740
      • 95 Posts
      getResourcesTag might do it for you, see:

      http://modxcms.com/forums/index.php/topic,58729.msg334962.html#msg334962

      Personally I couldn’t get it to work and intend to use Evolution instead.
        • 29019 ☆ A M B ☆
        • 104 Posts
        This is just off the top of my head, but it should look something like this for your input option values on the TV (with checkbox for the input type, or whichever you prefer):

        @EVAL return $modx->runSnippet('getResources',array('parents'=>PARENT_ID, 'tpl'=>'tv-option', 'limit'=>0));


        Make sure you set up a ’tv-option’ chunk that looks something like this:
        [[+pagetitle]]==[[+id]]


        Alternatively, you could have your getResources call go through the whole site, and limit based on template instead:
        @EVAL return $modx->runSnippet('getResources',array('parents'=>0, 'tpl'=>'tv-option', 'limit'=>0, 'where'=>'{"template:=":PRODUCT_TEMPLATE}'));


        Of course there are plenty of sorting options also, but that should get you started.
          www.darkstardesign.com

          Are you in the Nashville area? Join us for our next MODX meetup!
          • 2740
          • 95 Posts
          Thanks swespi that is really helpful and far better than my suggestion.

          I only had to make a couple of minor changes to get checkboxes to display.

          These I found here:
          http://modxcms.com/forums/index.php?topic=54275.0


          To the @EVAL call add ’context’ => ’web’ and ’tplLast’=>’tv-optionLast’ and if you have your resources hidden like I do then ’showHidden’ => 1

          @EVAL return $modx->runSnippet('getResources',array('parents'=>PARENT_ID, 'tpl'=>'tv-option', 'tplLast'=>'tv-optionLast', 'limit'=>0, 'context' => 'web', 'showHidden' => 1));


          For the tv-option chunk

          [[+pagetitle]]==[[+id]]||


          For the tv-optionLast chunk

          [[+pagetitle]]==[[+id]]