Community

Using logic in getResources tvFilters

I’m trying to convert an old Evo Ditto call to a Revo getResouces call. The old ditto is:

[[Ditto? &parents=`21` &orderBy=`menuindex ASC` &depth=`0` &tpl=`nhsPopulateData2` &noResults=`blankDittoProducts` &tagDelimiter=`,` &tagData=`nhs_application` &tagMode=`onlyTags` &tags=`[*id:is=`23`:then=`56`:else=`[*id:is=`25`:then=`59`:else=`[*id:is=`26`:then=`60`:else=`[*id:is=`24`:then=`57`:else=`[*id:is=`43`:then=`58`*]`*]`*]`*]`*]` &filter=`nhs_material-type,[+id+],1`]]

I want to vary the application depending on the material-type so that I get the documents that have nhs_material-type is 23 only when the nhs_application = 56 , etc.

I can’t figure out a way to get the if then logic to work in getResources. The following will work but obviously doesn’t give me what I need:

[[getResources? 
  &parents=`21` 
  &sortby=`menuindex`
  &sortdir=`ASC`
  &tpl=`nhsPopulateData2`
  &tagDelimiter=`,`
  &tvFilters=`nhs_material-type==[[+id]],nhs_application==%56%`
  &includeTVs=`1` 
  &tvPrefix=``
  &limit=`0`
  &depth=`1`
]]

If I try to put the if-then logic in place of the %56%, I get no results. I also tried using the &when property but I don’t think I understand the syntax fully and couldn’t get that to work either.
This it even possible to use logic in the &tvFilters property? Anybody have a way to make this work?

put the if then logic in your template for the output, then it can parse the resulting data and deliver the right output

Try these:

&tvFilters=nhs_material-type==[[+id]],nhs_application=%56%
&tvFilters=nhs_material-type==[[+id]],nhs_application==56
&tvFilters=nhs_material-type==[[+id]],nhs_application=56

Also make sure that the TV is set for each individual resource and doesn’t use the default value of the TV.