On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Great! That returned the required 3x results in raw 'string' format in the content area. This is what I did:

    • in a 'normal' resource I pasted the gR snippet call into the content area
    • made the chunk as per your recomm
    • page renders with 3x latitude TVs

    It appears to work in a different context, big thanks for that lead.

    So from that I tried what is I guess a really clunky approach and just added the map id div and all of the relevant script into the content area of another normal resource (ie a resource set to content type html). The whole map renders but I'm getting exactly the same problem, the 3 json objects showing in the script with data only from the 1st resource polled by getResources.

    For the record I'm also clustering these returned map markers with the g-map clustering script - I'm getting the 3 markers clustered together on the map, as per what the 3x json objects would imply, but they won't expand when clicked/zoomed. But I guess this is just an abstraction from the root problem here.

    Right now I need to put this down for the night but will be back on it early tomorrow. Thanks for the help so far.
    • do it in little steps, then show your whole code, at the last step, which works and the first step, which doesn't work.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
      • Quote from: Bruno17 at Aug 02, 2017, 06:13 AM
        do it in little steps, then show your whole code, at the last step, which works and the first step, which doesn't work.
        I put both gR calls into the new resource content area and interestingly I got 2 different responses, correct and incorrect. Your suggestion returns the 3 different Latitudes perfectly, my original templates still only return data from the one resource.

        Here's the 2 calls exactly:
        [[!getResources? 
        &parents=`26` 
        &tpl=`simpleMapChunk` 
        &showHidden=`1` 
        &includeTVs=`1` 
        &processTVs=`1` 
        &limit=`20`
        ]]
        
        simpleMapChunk:
        [[+tv.map-latitude]]
        

        This returns tv.map-latitude correctly, 3 different versions.
        [[!getResources? 
        &parents=`26` 
        &tpl=`tplWrapperGMapVars` 
        &tplLast=`tplWrapperGMapVarsTail` 
        &showHidden=`1` 
        &includeTVs=`1` 
        &processTVs=`1` 
        &limit=`20` 
        &debug=`1`]]
        
        tplWrapperGMapVars and tplWrapperGMapVarsTail both use the following:
        lat: [[+tv.map-latitude]],
        lng: [[+tv.map-longitude]],
        info: '<div class="info_content"><h3>[[+tv.map-location]]</h3><p>[[+tv.map-description]]</p></div>'
        

        This still returns 3x the same, polled from the 1st resource.
        fyi, I tweaked the chunk templates a little to remove the '+' concatenation characters, just incase it was messing.

        From here I don't know what to do; this testing is inserting the gR calls into [*content] but for the map to render as required I need the gR call (i.e. the json objects) to be inside the body of the google map api script. That seems catch22 to me right now, am I missing something glaringly obvious?

        • without &tplLast, what happens then?
          btw: you don't need this &tplLast at all, but you can have
          &outputSeparator=`,`
          
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
          • maybe one of us could have a quick look into your manager?
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
            • Quote from: Bruno17 at Aug 02, 2017, 09:52 AM
              without &tplLast, what happens then?
              btw: you don't need this &tplLast at all, but you can have
              &outputSeparator=`,`
              
              Aha, 'tplLast' is a good tip, added it have correct json formatting - the problem remains though sad

              I've added one more tv to the 'good' gR return block (location name) and it still works fine. Below is a straight copy of what's output in the page with the correct returns in italics. You can see the 3x json objects below that, each returning from the 1 resource:

              Location 01 - 46.184570
              Location 02 - 46.179147
              Location 03 - 46.190244

              { lat: 46.184570, lng: 6.697508, info: '
              Location 01
              Spicy jalapeno bacon ipsum dolor amet burgdoggen beef beef ribs shankle, landjaeger kevin chicken leberkas corned beef t-bone ribeye swine bresaola. Pastrami shoulder hamburger picanha doner spare ribs chuck pig fatback cupim turkey turducken beef cow.

              ' },{ lat: 46.184570, lng: 6.697508, info: '
              Location 01
              Spicy jalapeno bacon ipsum dolor amet burgdoggen beef beef ribs shankle, landjaeger kevin chicken leberkas corned beef t-bone ribeye swine bresaola. Pastrami shoulder hamburger picanha doner spare ribs chuck pig fatback cupim turkey turducken beef cow.

              ' },{ lat: 46.184570, lng: 6.697508, info: '
              Location 01
              Spicy jalapeno bacon ipsum dolor amet burgdoggen beef beef ribs shankle, landjaeger kevin chicken leberkas corned beef t-bone ribeye swine bresaola. Pastrami shoulder hamburger picanha doner spare ribs chuck pig fatback cupim turkey turducken beef cow.

              ' }

              If you could have a peek in the manager that would be much appreciated. Can pm you details, that ok?

              • If you could have a peek in the manager that would be much appreciated. Can pm you details, that ok?

                ok
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                • discuss.answer
                  you didn't say, that there is a chunk in your tpl.
                  Each modx-tag has to have a unique footprint (different properties) within one request.
                  If you call the same MODX - tag with the same footprint (same properties), for example a chunk, two or more times, the first one is cached for the whole request.
                  This is for speeding reasons, if you call the same snippet or chunk with the same properties more than once only the first one has to be processed. The next ones get the output from an internal cache.

                  The solution is simple. Call your chunk within the tpl like that:

                  [[$tplCodeblockGMapVarsLITE? &id=`[[+id]]`]]
                  


                  Quote from: Bruno17 at Aug 01, 2017, 02:59 PM
                  Sounds like that isn't the issue, because the OP sees three items, but only with the same values for each item.
                  Maybe a strange placeholder-caching-issue?
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                  • Quote from: Bruno17 at Aug 03, 2017, 04:23 AM
                    you didn't say, that there is a chunk in your tpl.
                    In the opening post I put this:
                    tpl.wrapper-GMapVars and tpl.wrapper-GMapVars-Tail are identical but 'GMapVars-Tail' omits trailing comma for correct JSON syntax, and both use a chunk for the TV's/JSON object properties: ...

                    But I can see that this could easily be missed/misinterpreted, and whatsmore, Bruno your solution I wouldn't have got anyway wink
                    This is the accepted answer because it works! I've learnt through this, many thanks.

                    • and both use a chunk for the TV's/JSON object

                      Ah, I see now. Sorry! Allways better to show us all your code. We are better in reading code, than reading words wink

                      I'm glad, this is solved!
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!