We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 53376
    • 32 Posts
    EN: I need to select all resources with template №1 AND ([with current resource as parent] OR [resources which has TV showin parameter contains ID of current resource]). How to build this query?
    RU: Мне нужно выбрать все ресурсы с шаблоном №1 И ([текущим ресурсом в качестве родителя] ИЛИ [ресурсы у которых доп.поле showin содержит ID текущего ресурса]). Как построить этот запрос?

    WHERE template=1 AND (parent=[[*id]] OR showin LIKE '%[[*id]]%')



    EN: What I tried:
    RU: Что Я попробовал:

    &where=`{"template":1},{"parent":[[*id]],"OR:showin:LIKE":"%[[*id]]%"}`

    &where=`{"template":1","AND:":{"parent":[[*id]],"OR:showin:LIKE":"%[[*id]]%"}}`

    &where=`{{"template":1},{"AND:parent:=":[[*id]],"OR:showin:LIKE":"%[[*id]]%"}}`

    &where=`{["template":1],["AND:parent:=":[[*id]],"OR:showin:LIKE":"%[[*id]]%"]}`
    [ed. note: i_am_bars last edited this post 7 years ago.]
      • 42892
      • 44 Posts
      Not shure how I would do the OR but in getResources Snippet you have the where and tvFilter Parameters.

      One way you could do it, is to remove the parent from your query and give your showin TV an default value of [[*parent]]. Now you can query the resources like this.

      &where=`{"template":1}`
      &tvFilter=`showin==%[[*id]]%`

      I havent tested it. Hope it helps smiley
        • 53376
        • 32 Posts
        Okay, but OR is actual. I need to get resources with

        &tvFilter=`showin==%[[*id]]%`

        OR
        &parents=`[[*id]]`


        And do them both just in one &query parameter
          • 42892
          • 44 Posts
          Saw your response just yet. I don't think that this is possible. If your not willing to simply make your logic simpler (what would be my recommendation) you can only make a snippet which has three getResources calls in it (all 3 params match, 2 params match, one param match), then you can merge and sort the found resources, then you can gather these ids and run getResources again with &parents=`-1` &resources=`list of ids` to return the output you want.

          Again, hope it helps wink