We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17552
    • 46 Posts
    Hi togehter,

    I want to use MIGX in the following scenario (simplified form):

    Users can create data records containing fields title and category. The output should aggregate the field category (like GroupBy in SQL) to arrange the output, e.g.

    <h1>A Category</h1>
    <div>An Item 01</div>
    <div>An Item 02</div>
    
    <h1>Another Category</h1>
    <div>An Item 03</div>
    <div>An Item 04</div>
    <div>An Item 05</div>
    <div>An Item 06</div>
    
    ...
    


    Is that possible with MIGX? When yes, how?


    Kind regards,
    Kersten

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

    • discuss.answer
      • 4172
      • 5,888 Posts
      maybe something like that could work:

      in your tpl:
      [[+category:isnot=`[[+oldcategory]]`:then=`
      <h1>[[+category]]</h1>
      `:else=``]]
      [[!setPlaceholder? &placeholder=`oldcategory` &value=`[[+category]]`]]
      <div>An Item [[+idx]]</div>


      create a snippet 'setPlaceholder':
      $modx->setPlaceholder($placeholder,$value);

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

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 17552
        • 46 Posts
        Hi Bruno,

        thanks for your advice. Your approach works, although I had to enable caching in the snippet setPlaceholder before:

        [[setPlaceholder? &placeholder=`oldcategory` &value=`[[+category]]`]]
        


        It is not really nifty but who cares...
        Great plugin you created!

        Best regards,
        Kersten