We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 48657
    • 17 Posts
    hey , lets say my mifxloopcollection gives me blocks of entries, that are orderd by date. in this case my table-column for this is "eventdate"


    This is my calling procedure:
    [[!migxLoopCollection? &packageName=`abc` &classname=`Abc` &tpl=`templateAbc` &sortConfig=`[{"sortby":"eventdate","sortdir":"ASC"}]`]]
    


    This is my (templateAbc) chunk code:
    <blockquote>
    <div class="entry">
    [[+eventname]]
    </div>
    </blockquote>


    how can i group those blocks by date ?

    for example

    -27/08/2014-
    Event 1
    Event 2
    Event 3

    -28/08/2014-
    Event 4
    Event 5

    -29/08/2014-
    ...

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

    • discuss.answer
      • 4172
      • 5,888 Posts
      you can try this:

      create a snippet 'getChunkIfNewValue'

      <?php
      
      $current_value = $modx->getOption('value',$scriptProperties,'');
      $tpl = $modx->getOption('tpl',$scriptProperties,'');
      $old_value = $modx->getPlaceholder('current_value');
      
      $output = '';
      
      if ($current_value != $old_value){
          $output = $modx->getChunk($tpl,$scriptProperties);
      }
      
      $modx->setPlaceholder('current_value',$current_value);
      
      return $output;
      


      put it into your tpl-chunk:

      [[!getChunkIfNewValue? &value=`[[!+eventdate:strtotime:date=`%d/%m/%Y`]]` &idx=`[[!+idx]]` &tpl=`tplNewDate`]]
      <div class="entry">
      [[+eventname]]
      </div>


      and have a chunk tplNewDate with:

      <h3>[[!+value]]</h3>




        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 48657
        • 17 Posts
        This worked like charme !
        Thank you so much Bruno. Great work once again !!