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

    Maybe I’m just not thinking far enough but I’m wondering if someone has a smart solution for my problem.

    I use lots of different TVs (like language, country, institute, year, author, etc.) in my documents and would like to apply user generated filters to them to get only the resources I’m looking for. Of course, I thought about using getResources with the tvFilters option. A function would then generate the corresponing tvFilters string out of the arguments set by the user. It looks like brackets aren’t currently supported in the getResources snippet. So, the example below doesn’t really work:
    [[!getResources? &parents=6 &includeTVs=1 &tpl=defaultView &tvFilters=`language==English,(country==DE||country==UK||country==FR)`]]

    I know that in this specific example I could arrange them in a different way by adding the `language==English` with an AND before or after every `country==XX` to get the correct result. But this gets quite complicated if I need to filter for even more TVs than just these two. For example, the following SQL pseudo code would result in an very, very long tvFilters string and I don’t even know if it would work:
    SELECT resource FROM myResources WHERE lanuage = English AND (country = DE OR country = UK) AND (year BETWEEN 2008 AND 2010) AND (author = Bill OR author = James)

    So, any ideas? Or is there a way to implement such a functionality with xPDO querys?

    Thanks for hints and suggestions,
    Lukas
      • 4172
      • 5,888 Posts
      Its a bit tricky to create sql-statements like that for TVs and I think at some point they are slow.
      If you don’t want to store this records in a custom-table at all (what I would prefer), you could create one for searching, where you have mirror of your resources including TVs.
      Its faster and a lot easier to generate sql-statements for searching this table.
      You could create a script which generates the sql-statement out of your filter-string and let return a resource-ID-list for getResources.
      BloX has functions, which does that for evo (for resources and TVs or for custom-tables).

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

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!