We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40762
    • 54 Posts
    Hello everybody,

    I have been facing this issue this evening concerning duplicates of value for one of the field.

    I am suspecting the caching to be the issue although I might be wrong.

    This is the tab config

    [
    {"caption":"Country List", "fields": [
        {"field":"city","caption":"City"},
        {"field":"country","caption":"Country","inputTV":"country"}
    ]}
    ]


    This is the grid config
    [
    {"header": "City", "width": "160", "sortable": "true", "dataIndex": "city"},
    {"header": "Country", "width": "100", "sortable": "false", "dataIndex": "country"}
    ]


    I am rendering the result in a chunk and the code looks like this

    [[!getImageList?
        &tvname=`countryList`
        &tpl=`countryTpl`
        &docid=`[[+id]]`
      ]]


    on the backend side things are working fine but when it comes to the frontend I only get the first rendered item.

      Marc-Andre Audet
      • 4172
      • 5,888 Posts
      Seems to be the same issue like here:
      http://forums.modx.com/thread/80762/getimagelist-used-in-getresources-rowtpl-only-shows-data-from-first-item#dis-post-445183

      Never could reproduce this.

      What is your getResources - tag?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 40762
        • 54 Posts
        Hey Bruno,

        I am actually not using any getResource for that one. I am using a custom snippet

        this is the code
        [[relatedArtistsEvent? &input=`[[*artists]]` &tpl=`eventRelatedArtistsTpl`]] 
        


        this is relatedArtistsEvent snippet

        <?php
        if (empty($input)) { 
        
        return 'This article is so unique, that we couldn\'t find anything related to it!'; 
        }
        $tpl = $modx->getOption('tpl',$scriptProperties,'relatedPagesTpl');
        if ($modx->getChunk($tpl) == '') { 
        
        return 'We found some related pages, but don\'t know how to present it.'; 
        }
        $ids = explode(',', $input);
        $output = array();
        foreach ($ids as $key => $value) {
        
        $id=$modx->runSnippet("BabelTranslation",   array(
                    "contextKey" => $modx->context->key, "resourceId" => $value)); 
        
        
          $resource = $modx->getObject('modResource',array(
            'published' => 1,
            'id' => $id));
          if ($resource instanceof modResource) {
            $output[] = $modx->getChunk($tpl,$resource->toArray());
          }
        }
        return implode('<br/> ',$output);


        and this is the chunk eventRelatedArtistsTpl

          <a href="[[~[[+id]]]]" title="[[+pagetitle]]">
            [[+longtitle:default=`[[+pagetitle]]`]]
            
          </a>
          <br/>
        
        <p class="country">
        
        [[!getImageList?
            &tvname=`countryList`
            &tpl=`countryTpl`
            &docid=`[[+id]]`
          ]]
        
        </p>


        It looks like the link above is alot related even if we are not dealing with the same kind of data. I will try to make it work with a placeholder and see the outcome.

        I also have this problem although I have strong doubt that those two are related (or maybe they are?!?)

        http://forums.modx.com/thread/81434/country-renderer-based-on-key-issue#dis-post-449054

        [ed. note: markodey last edited this post 11 years, 4 months ago.]
          Marc-Andre Audet
          • 40762
          • 54 Posts
          Ok, I have tried the solution for this issue and it is not working.

          http://forums.modx.com/thread/80762/getimagelist-used-in-getresources-rowtpl-only-shows-data-from-first-item#dis-post-445183

          The two problems are actually quite different. His case is concerning resource id mine is concerning overriding a value while parsing the value of a field.

          I am thinking of programming my own snippet of which it will parse the data and display it. I will get you guys back on the result.
            Marc-Andre Audet
            • 3749
            • 24,544 Posts
            I imagine you've tried this, but in case not:

            [[!relatedArtistsEvent? ... ]]
              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
              • 40762
              • 54 Posts
              So as mentionned in my previous post. Here is my little snippet I programmed. Very basic and ugly. If any of you guys have suggestion to improve it tell me so.

              $resource = $modx->getObject('modResource',$id);
              
              $itemSeperator=',';
              $seperator='<br>';
              $output='';
              
              
              
              
              if (!($resource instanceof modResource)) { return ''; }
              
              $country_list=json_decode($resource->getTVValue('countryList'));
              
              $lang=$modx->context->key;
              
               if($lang=='en'){
              
              $_country_lang = array();
              include $modx->getOption('core_path').'lexicon/country/en.inc.php';
              
              }
              
              if($lang=='web'){
              
              $_country_lang = array();
              include $modx->getOption('core_path').'lexicon/country/fr.inc.php';
              
              
              }
              
              
               ///Iterating through countries
               foreach($country_list as $place) {
              
               $city=$place->city;
               $country_key=$place->country;
                
               $output.=$city;
               $output.=$itemSeperator;
               
               ///Getting the country by its key
               foreach ($_country_lang as $key =>$value) {
              
                
                 if($key==$country_key){
                     
                       $output.=$value;
              
                 }
              
              }
              
              $output.=$seperator;
              
              }
              
              
              
              return $output;


              Here is to call it

              [[!getCountryList?
                &id=`[[+id]]`
              
              ]]


              Thanks for now!

              Maybe next move would be to port a portion of the code to getImageList so it works (just to avoid using 100s of snippet to do the same thing)
                Marc-Andre Audet
                • 40762
                • 54 Posts
                Quote from: BobRay at Jan 03, 2013, 10:00 PM
                I imagine you've tried this, but in case not:

                [[!relatedArtistsEvent? ... ]]


                I honestly haven't tried it. but I just tried it and... it didn't work. Could you remind me what is the exact difference.

                thanks
                  Marc-Andre Audet
                  • 3749
                  • 24,544 Posts
                  With the exclamation point, the snippet is called uncached, so you get a fresh result rather than the cached result from the last run.
                    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