We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36613
    • 328 Posts
    I have this situation:
    - Product 1 (ID:82)
    - Product 2 (ID:1182)
    - Product 3 (ID:1822)
    - Product 4 (ID:51)

    And i have a list of news with multi-select box related of products:
    - News 1 -> Product 2;Product 3 (prod_rel_id:1182,1822)
    - News 2 -> Product 2;Product 4 (prod_rel_id:1182,51)
    - News 3 -> Product 1;Product 4 (prod_rel_id:82,51)

    In page of "Product 1" i want have the related news to "Product 1" products. What can I do?
    I try this solution but don't work:

    &tvFilters=`prod_rel_id==%82%`

    don't work because the filter take me all news and because in the "prod_rel_id" variabiles there is the "82" number. I want return only the News 3 for Product 1 .

    This question has been answered by Bruno17. See the first response.

    [ed. note: cristianb88 last edited this post 9 years, 9 months ago.]
      • 3749
      • 24,544 Posts
      I could be wrong, but I don't think there's any way to do that without a custom snippet because you have more than one ID in the TV.

      I think this might do it (untested):

      [[!GetTvRelated? &docs=`[[*prod_rel_id]]`]]


      DocTpl Chunk:

      <p><a href="[[~[[+id]]]]">[[+pagetitle]]</a></p>


      GetTvRelated snippet:

      <?php
      /* GetTvRelated snippet */
      
      $docs = $modx->getOption('docs', $scriptProperties, array());
      $output = '';
      
      if (! empty($docs)) {
          $docs = explode(',', $docs);
          foreach($docs as $doc)  {
              $r = $modx->getObject('modResource', $doc);
              if ($r) {
                  $output .= $modx->getChunk('DocTpl', $r->toArray());
              }
          }
      }
      return $output;
      
      
      [ed. note: BobRay last edited this post 7 years, 10 months ago.]
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
      • discuss.answer
        • 4172
        • 5,888 Posts
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 36613
          • 328 Posts
          Quote from: BobRay at Jul 15, 2014, 05:28 AM
          I could be wrong, but I don't think there's any way to do that without a custom snippet because you have more than one ID in the TV.

          If think this might do it (untested):

          [[!GetTvRelated? &docs=`[[*prod_rel_id]]`]]


          DocTpl Chunk:

          <p><a href="[[~[[+id]]]]">[[+pagetitle]]</a></p>


          GetTvRelated snippet:

          <!--?php
          /* GetTvRelated snippet */
          
          $docs = $modx--->getOption('docs', $scriptProperties, array());
          $output = '';
          
          if (! empty($docs)) {
              $docs = explode(',', $docs);
              foreach($docs as $doc)  {
                  $r = $modx->getObject('modResource', $doc);
                  if ($r) {
                      $output .= $modx->getChunk('DocTpl', $r->toArray());
                  }
              }
          }
          return $output;
          
          

          Hi bob, in the products page i don't have the list of id because a filter the id of the page.
          This is my getresource:

          [[!getResources?
          &parents=`[[++news_id]]`
          &depth=`1`
          &limit=`0`
          &includeTVs=`1`
          &prepareTVs=`1`
          &includeContent=`1`
          &tplWrapper=`el-items-Wrapper-news`
          &tpl=`el-items-news-homepage`
          &tvFilters=`[[*id]]`
          &sortby=`{"publishedon":"DESC","createdon":"DESC"}`
          ]]
            • 36613
            • 328 Posts
            Quote from: Bruno17 at Jul 15, 2014, 07:43 AM
            to get exact tag-results from multi-select, see also this one


            http://forums.modx.com/thread/82476/why-tagging-doesn-039-t-work-in-revo-and-how-to-solve-this?page=2#dis-post-494448

            Ok this is the solution but i have a question. I want filter for parent e and specific resource but this script don't work:

            [[!migxLoopCollection?
            &classname=`modTemplateVarResource`
            &where=`{"tmplvarid":"19","1":[
            {"value":"[[*id]]"},
            {"OR:value:LIKE":"%||[[*id]]||%"},
            {"OR:value:LIKE":"[[*id]]||%"},
            {"OR:value:LIKE":"%||[[*id]]"}
            ]}`
            &tpl=`@CODE:[[+contentid]]`
            &outputSeparator=`,`
            &toPlaceholder=`resource_ids`
            ]]

            [[!pdoResources?
            &parents=`[[++news_id]]`
            &includeTVs=`1`
            &prepareTVs=`1`
            &showHidden=`1`
            &resources=`[[!+resource_ids]]`
            &tpl=`el-items-news-homepage`
            &depth=`10`
            ]]

            if i set parents = 0 work, but i want take the resources under [[++news_id]] not in all site.
              • 4172
              • 5,888 Posts
              does this work?

              [[!pdoResources?
              &parents=`0`
              &includeTVs=`1`
              &prepareTVs=`1`
              &showHidden=`1`
              &where=`{"parent":"[[++news_id]]","id:IN":[ [[!+resource_ids]] ]}`
              &tpl=`el-items-news-homepage`
              &depth=`10`
              ]]
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!