Ergebnis 1 bis 11 von 11

Thema: Test MM : how-to filter on a linked field (select) ?

  1. #1
    Contao-Nutzer
    Registriert seit
    07.11.2012.
    Beiträge
    106

    Frage Test MM : how-to filter on a linked field (select) ?

    Hi everyone,

    I'm testing MetaModels (Contao3 - dev-contao3 @ c18945) with a Contao 3.2 installation. I have to develop a module to display cultural events. These events :
    - are grouped by season (ie : 2013/2014, 2014/2015…)
    - group different dates.

    For the moment, I've created :
    - a MM Seasons with title (text) ; start date (date) ; end date (date);
    - a MM Events with at first a select field seasons which is linked to MM season (id column : id ; value : title_season).

    In the front-end, I want to display only the events corresponding to season_startdate =< today =<season_enddate ? I've tried with filter but didn't find anyway.
    I thought to add a checkbox for the user can check which is the active season but the question remains the same : how to filter "I want to display event where the selected season is the active one".

    thanks for your help.
    Geändert von Charled (29.04.2015 um 14:02 Uhr)

  2. #2
    Contao-Urgestein Avatar von KlausGrenoble
    Registriert seit
    27.01.2013.
    Ort
    Grenoble
    Beiträge
    2.362

    Standard

    Je crois, qu'il faudrait utiliser le filtre " Custom SQL [customsql]" comme ici:
    http://contao.klausgraf.fr/metamodel...mp-filter.html
    Salutations Klaus

  3. #3
    Contao-Urgestein Avatar von zonky
    Registriert seit
    19.03.2010.
    Ort
    Berlin, Rdf
    Beiträge
    9.719
    User beschenken
    Wunschliste

    Standard

    Hi Charled,

    I'm not sure whether I heard you...

    you have a mm_events with a 1:n relation to mm_season? with items at mm_events

    event-1 => season 2013/14
    event-2 => season 2013/14
    event-3 => season 2015/16
    event-4 => season 2017/18

    correct?

    you can make a filter with the items of season e.g. with a pull-down select

    the filter item "season 2013/14" give you the items "event-1" and "event-2"

  4. #4
    Contao-Urgestein Avatar von KlausGrenoble
    Registriert seit
    27.01.2013.
    Ort
    Grenoble
    Beiträge
    2.362

    Standard

    Zitat Zitat von zonky Beitrag anzeigen
    a filter with the items of season e.g. with a pull-down select
    Indeed, I think this is the way to proceed. Très bien !

  5. #5
    Contao-Nutzer
    Registriert seit
    07.11.2012.
    Beiträge
    106

    Standard

    Zitat Zitat von zonky Beitrag anzeigen
    Hi Charled,

    I'm not sure whether I heard you...

    you have a mm_events with a 1:n relation to mm_season? with items at mm_events

    event-1 => season 2013/14
    event-2 => season 2013/14
    event-3 => season 2015/16
    event-4 => season 2017/18

    correct?

    you can make a filter with the items of season e.g. with a pull-down select

    the filter item "season 2013/14" give you the items "event-1" and "event-2"
    Hi Zonky,

    Thanks for your answer. You're right for the link but I will only display one saison at a time. So I don't need a pull-down select for visitors can choose which season they want to see. I just want the ebents to be automatically selected based on the active season : using the dates [ selectedseason::startdate => today <= selectedseason::enddate ] or simply a checkbox "Season-Active season" (so the BE user can choose when the season changes).

  6. #6
    Contao-Nutzer
    Registriert seit
    07.11.2012.
    Beiträge
    106

    Standard

    Zitat Zitat von KlausGrenoble Beitrag anzeigen
    Je crois, qu'il faudrait utiliser le filtre " Custom SQL [customsql]" comme ici:
    http://contao.klausgraf.fr/metamodel...mp-filter.html
    Salutations Klaus
    Thanks Klaus ;-)) If I guessed you will answer, I would have post on the french forum. Even if I suppose we meet more MM user on this one ;-))

  7. #7
    Contao-Urgestein Avatar von zonky
    Registriert seit
    19.03.2010.
    Ort
    Berlin, Rdf
    Beiträge
    9.719
    User beschenken
    Wunschliste

    Standard

    Hi Charled,

    you can try this with a filter as "own sql" with a subselect

    like

    PHP-Code:

    SELECT 
    FROM mm_events WHERE season_id = (SELECT id FROM mm_season WHERE NOW()>FROM_UNIXTIME(date_start) and NOW() < FROM_UNIXTIME(date_end))
    // untested !! 
    a good way is to work with phpMyAdmin and copy the sql at your filter...

  8. #8
    Contao-Nutzer
    Registriert seit
    07.11.2012.
    Beiträge
    106

    Standard

    Thanks. I'll test.

  9. #9

  10. #10
    Contao-Nutzer
    Registriert seit
    07.11.2012.
    Beiträge
    106

    Multimedia

    Zitat Zitat von zonky Beitrag anzeigen
    PHP-Code:
    SELECT FROM mm_events WHERE season_id = (SELECT id FROM mm_season WHERE NOW()>FROM_UNIXTIME(date_start) and NOW() < FROM_UNIXTIME(date_end))
    // untested !! 
    This works fine. Vielen danke !

  11. #11

Aktive Benutzer

Aktive Benutzer

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)

Lesezeichen

Lesezeichen

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •