1

I have a section (events) with a Super Table field that has a date field. I am looking for a way to make a request to have the events superior to now. I cannot find how to do it. The event have multiple dates. Thanks for your help.

2

It's basically the same as Find entries that use a specific block in their Matrix field?

You can use the base query and left join your Super Table content row

{% set entries = craft
    .entries()
    .section(['your-section'])
    .leftJoin('{{%supertableblocks}} as supertableblocks', '[[supertableblocks.ownerId]] = [[entries.id]]')
    .leftJoin('{{%stc_content}} as stc_content', '[[stc_content.elementId]] = [[supertableblocks.id]]')
    .andWhere(['>=', 'stc_content.field_date', entry.date|date('atom')]) 
    .groupBy('supertableblocks.ownerId')
    .all()
%}

Note: this is untested, maybe you need certain modifications it should just be some kind of guidance. Please keep in mind to replace your actual table and field names. I just used stc_content as a demonstration as well as stc_content.field_date

  • great thank you, I had not seen the tables created by the plugin. Thanks it works now – Patrick Faramaz Aug 20 '18 at 8:57
  • I get a SQL error when setting groupBy that says it's incompatible with MySql 5.7's sql_mode=only_full_group_by setting. Any way to modify to avoid the error? – kmgdev Dec 1 at 1:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.