We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51020
    • 670 Posts
    Quote from: Bruno17 at Jun 24, 2016, 10:09 AM
    Didn't you say, you have your tags now changed to tagger instaed of the TV?

    Another route I thought about was to choose related products from a resourcelist. the problem is that i need to import all my products, and there are several thousand, and i won't know their resource IDs as they won't exist at that stage.

    So I just need a way to pull in resources whos productcode matches a value in my comma-separated tags.

    Sounds simple, but it's making my head hurt...

      • 4172
      • 5,888 Posts
      Add also the own productcode to the tags.
      So at product with productcode 0000 have 0000,1111,2222,3333

      Then, on product 0000, you will get all resources which have the tag 0000,1111,2222 or 3333 but not the current product, with my snippet-call.
      It will allways search for products, which have one of the tags, of the current resource.

      Isn't it that, what you want?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 51020
        • 670 Posts
        Quote from: Bruno17 at Jun 24, 2016, 10:57 AM
        Add also the own productcode to the tags.
        So at product with productcode 0000 have 0000,1111,2222,3333

        Then, on product 0000, you will get all resources which have the tag 0000,1111,2222 or 3333 but not the current product, with my snippet-call.
        It will allways search for products, which have one of the tags, of the current resource.

        Isn't it that, what you want?

        Thanks - but how would I identify which of the string of productcodes (tags) is for the current product?
        I need to display the product code for each product in the TPL for the current product - eg:
        <img src="[[+productimage]] /> <!-- product image -->
        <h2>[[+pagetitle]]</h2> <!-- product name -->
        <p>[[+productcode]]</p> <!-- product code -->
        <h3>[[+introtext]]</h3> <!-- product text -->
        
        
        Then in the tpl for the related products I need:
        
        <p>[[+pagetitle]]</p> <!-- product name -->
        <p>[[+productcode]]</p> <!-- product code -->
        <p>[[+introtext]]</p> <!-- product text -->
        
        


        I don't really understand how the snippet call you supplied will be able to pull out all the product codes and know which one to use as the 'hero' product, and which to use as the 'related products'.

        Sorry If I'm missing the point.

        Andy
          • 4172
          • 5,888 Posts
          take this snippet-call

          [[TaggerGetRelatedWhere? &groups=`1`]]

          make sure, you use the correct tagger-group-id

          and post here, what it returns.

          this snippet
          https://github.com/modxcms/Tagger/blob/master/core/components/tagger/elements/snippets/taggergetrelatedwhere.snippet.php

          takes the tags of the current resource and creates a query, to get all resources, which have one of the tags of the current resource.
          I added this snippet to tagger for exactly that, to get resources, which have related tags.
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 51020
            • 670 Posts
            Quote from: Bruno17 at Jun 24, 2016, 11:14 AM
            take this snippet-call

            [[TaggerGetRelatedWhere? &groups=`1`]]

            make sure, you use the correct tagger-group-id

            and post here, what it returns.

            this snippet
            https://github.com/modxcms/Tagger/blob/master/core/components/tagger/elements/snippets/taggergetrelatedwhere.snippet.php

            takes the tags of the current resource and creates a query, to get all resources, which have one of the tags of the current resource.
            I added this snippet to tagger for exactly that, to get resources, which have related tags.

            Ok I have added that - But I just get this:

            {"id:not IN":[67],"0":"EXISTS (SELECT 1 FROM `modx_tagger_tag_resources` r WHERE r.tag IN (2) AND r.resource = modResource.id)"} 
              • 4172
              • 5,888 Posts
              if you are inside another getResources - tpl, you can try:

              [[TaggerGetRelatedWhere? &groups=`1` &resources=`[[+id]]`]]
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 4172
                • 5,888 Posts
                {"id:not IN":[67],"0":"EXISTS (SELECT 1 FROM `modx_tagger_tag_resources` r WHERE r.tag IN (2) AND r.resource = modResource.id)"}
                


                yeah. The current resource is 67 and has only one tag, which is the tag with id 2
                This will get all resources, which have also the tag with that same id.
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 51020
                  • 670 Posts
                  Quote from: Bruno17 at Jun 24, 2016, 11:21 AM
                  if you are inside another getResources - tpl, you can try:

                  [[TaggerGetRelatedWhere? &groups=`1` &resources=`[[+id]]`]]

                  I tried adding this:
                     
                  [[getResources?
                  &tpl=`groupedProductsTpl`
                  &parents=`29`
                  [[TaggerGetRelatedWhere? &groups=`1`
                   &resources=`[[+id]]`]]
                    ]]
                   


                  And this does output a bunch of resources, but they have no relation to the tags i've created - it pulled in what looks like random resources (including a testimonials page, about us etc).

                    • 4172
                    • 5,888 Posts
                    well, you forgot the &where=

                    &where=`[[TaggerGetRelatedWhere? &groups=`1`&resources=`[[+id]]`]]`
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 51020
                      • 670 Posts
                      Quote from: Bruno17 at Jun 24, 2016, 11:24 AM
                      {"id:not IN":[67],"0":"EXISTS (SELECT 1 FROM `modx_tagger_tag_resources` r WHERE r.tag IN (2) AND r.resource = modResource.id)"}
                      


                      yeah. The current resource is 67 and has only one tag, which is the tag with id 2
                      This will get all resources, which have also the tag with that same id.

                      Ok - but how does it know what the productcode of the current product is, if it's mixed in with all the other related productcodes?

                      Sorry - I'm just not getting it!