Filter getResources results when value of TV matches a defined criteria

Sorry, was confused by your original post, which made no mention of the current resource’s ID and did not include it in the tag, though I see you did mention it later on in the thread and in your working example.

You also had this:

tvFilters=`matchedValue==%14%

and this:

[[!getCache? 
    &element=`getResources` 
    &resources=`[[*ELEMENT-WorkIndex-Top10Featured]]` 
    **&tvFilters=`ELEMENT-2019Project-WorkIndexSelections==%729%`** 
    ... 
]]

Both have a hard-coded value (14 and 729), but no reference to the ID of the current page.

Do you still want a hard-coded value in the tag, and if so what should it match?

From your latest description it sounds like using this tag might work:

[[GetTopTen? &selectionValue=`[[*id]]` &myTpl=`ActualTplName`]] 

I also can’t see how both these statements of yours can be true, but let’s save that topic until the main part works (or we give up :wink: ).

the CMS user can set a different image to render on the different resources the getResources call is placed on.

But the page the getResources call is on is not anything to do with the value of the image TVs

1 Like

Hi Bob - The value of

tvFilters=`matchedValue==% 729%

IS the page resource ID that the getResources call is on :wink: That’s all I want to achieve. So back to basics as below:

What I am looking for is a way to review the contents of the TV “ELEMENT-WorkIndex-Top10Featured” on the current resource (where the getResources call is) - and then look at the resources which that TV returns (it returns a list of resource IDs), viewing these resource IDs - look at the TV “ELEMENT-2019Project-WorkIndexSelections” of these returned resources and output from all this searching ONLY the resource IDs in the TV “ELEMENT-WorkIndex-Top10Featured”, that have a matching ID value in their TV"ELEMENT-2019Project-WorkIndexSelections" to the resource ID the getResources call is on.

1 Like

In that case, give this a try.

1 Like

Thanks Bob - I had that already :wink: It still returns resource IDs that it should not. e.g. of resources that dont match the criteria we are attempting to filter out.

1 Like

Could you explain the final goal? Maybe there is a better way of doing this, and also start using pdoResources, much faster and flexible.

1 Like

Hi Dimmy - I have a solution working using PHP IF statements and CSS to hide the results that we cant manage to get getResources to ignore - Happy to entertain the idea of pdoTools if it can be achieved in a better way yes. Brief is below:

I have a bunch of resources which I need to review/filter which are displayed based on a set of criteria. From the list of results I get from a getResources call, I am looking for a way to review the contents of the TV “ELEMENT-WorkIndex-Top10Featured” (which is a list of resource IDs) on the current resource (where the getResources call is) - and then look at the resources which that TV returns (it returns a list of resource IDs), viewing these resource IDs, then look at the TV “ELEMENT-2019Project-WorkIndexSelections” of these returned resources and output from all this searching ONLY the resource IDs in the TV “ELEMENT-WorkIndex-Top10Featured”, that have a matching ID value in their TV “ELEMENT-2019Project-WorkIndexSelections” to the resource ID the getResources call is on.

In simple(r) terms…

TV “ELEMENT-WorkIndex-Top10Featured" is a TV on the page where the getResources call is - this TV contains a list of resources which should be the results…

However… I want to be able to check these results and ONLY display ones which match an additional criteria …

That criteria being, that for each of the results, they each have a list of values in the TV they each have called “ELEMENT-2019Project-WorkIndexSelections”

IF the values in the TV “ELEMENT-2019Project-WorkIndexSelections” match the resource ID on which the getResources call is placed - then they are POSITIVE results and getResources should output them… If they don’t have a match in the list of values - then they are NEGATIVE results and should not be outputed by getResources as a result.

So, its really just an output filter of the results to scrutinise the TV “ELEMENT-2019Project-WorkIndexSelections” for each result to see if it has a matching value to the resource ID on which the getResources call is placed…

&tvFilters=`ELEMENT-2019Project-WorkIndexSelections==%CurrentResourceID%`

Was what I thought would work… but it doesn’t work for some reason… It still outputs FALSE results

1 Like

Are you sure that the ELEMENT-2019Project-WorkIndexSelections tv has comma seperated values in the database? or ||

So your getResources call has the folloing:
&resources=[[*ELEMENT-WorkIndex-Top10Featured]]

1 Like

Yep, if I output the TV on a page it renders as

741,750,768,781

getResources call is (noting that this is the getResources call when sitting on resource ID 729). So only results that have TV “ELEMENT-2019Project-WorkIndexSelections” with a match to value ‘729’ should be present in results.

[[!getCache? &element=`getResources` &resources=`[[*ELEMENT-WorkIndex-Top10Featured]]` &tvFilters=`ELEMENT-2019Project-WorkIndexSelections==%729%` &tpl=`ELEMENT-2019Work-Grid-ProjecTpl` &depth=`0` &limit=`10` &includeTVs=`1` &processTVs=`1` &tvPrefix=`` &sortby=`RAND()` &includeTVList=`ELEMENT-2019Project-WorkIndexProjectBlurb,ELEMENT-2019Project-WorkIndexSelections,ELE-2019Project-WorkIndexCoverIMG-ALL,ELE-2019Project-WorkIndexCoverIMG-EXPERTISE,ELE-2019Project-WorkIndexCoverIMG-EXPERTISE-CAT1,ELE-2019Project-WorkIndexCoverIMG-EXPERTISE-CAT2,ELE-2019Project-WorkIndexCoverIMG-EXPERTISE-CAT3,ELE-2019Project-WorkIndexCoverIMG-EXPERTISE-CAT4,ELE-2019Project-WorkIndexCoverIMG-EXPERTISE-CAT5,ELE-2019Project-WorkIndexCoverIMG-INDUSTRY,ELE-2019Project-WorkIndexCoverIMG-INDUSTRY-CAT1,ELE-2019Project-WorkIndexCoverIMG-INDUSTRY-CAT2,ELE-2019Project-WorkIndexCoverIMG-INDUSTRY-CAT3,ELE-2019Project-WorkIndexCoverIMG-INDUSTRY-CAT4,ELE-2019Project-WorkIndexCoverIMG-INDUSTRY-CAT5` ]]
1 Like

But you then also want to filter on all id’s that are in you local (current resource) tv: ELEMENT-WorkIndex-Top10Featured?

So if I understand this ok: you first get all resources that are in ELEMENT-WorkIndex-Top10Featured then see if those resources contains the current id in the tv with the name ELEMENT-2019Project-WorkIndexSelections ?

Or any id that is in ELEMENT-WorkIndex-Top10Featured can be in the target tv?

1 Like

Yes - that’s it - However, I don’t understand the last line in your comment as quoted below:

So - as an example, with getResources call on page ID ‘729’:

TV “ELEMENT-WorkIndex-Top10Featured” returns ‘741,750,768,781’

Then looking into these resources:

Resource 741 TV “ELEMENT-2019Project-WorkIndexSelections” values = ‘779,729,731’
Resource 750 TV “ELEMENT-2019Project-WorkIndexSelections” values = ‘779,729,733’
Resource 768 TV “ELEMENT-2019Project-WorkIndexSelections” values = ‘779,729,733,751’
Resource 781 TV “ELEMENT-2019Project-WorkIndexSelections” values = ‘779,751’

So…

GetResources should only output resources: 741,750 and 768
It should NOT output 781 (as it doesnt have the value ‘729’ in the TV “ELEMENT-2019Project-WorkIndexSelections”)

1 Like

try this:
&where = [{"ELEMENT-2019Project-WorkIndexSelections":"[[*id]]"},{"OR:ELEMENT-2019Project-WorkIndexSelections:LIKE":"%||[[*id]]"},{"OR:ELEMENT-2019Project-WorkIndexSelections:LIKE":"[[*id]]||%"},{"OR:ELEMENT-2019Project-WorkIndexSelections:LIKE":"%||[[*id]]||%"}]

I think the real seperator in the db is || if not replace all || for ,

1 Like

Thanks - I assume we also need backticks on the parameter? e.g.

&where=`[{"ELEMENT-2019Project-WorkIndexSelections":"[[*id]]"},{"OR:ELEMENT-2019Project-WorkIndexSelections:LIKE":"%||[[*id]]"},{"OR:ELEMENT-2019Project-WorkIndexSelections:LIKE":"[[*id]]||%"},{"OR:ELEMENT-2019Project-WorkIndexSelections:LIKE":"%||[[*id]]||%"}]`

Does’nt seem to work - now outputs nothing?

what does debug gives back? and maybe replace || for ,
&debug=1

&debug=`1`

Doesnt output anything… Does it work with the

[[!getCache? &element=`getResources`

code format?

Try it first without the caching snippet, just getResource only

Thanks - very odd - debug does’nt output anything… something odd going on… can you see any errors in this getResources call?

[[getResources? &resources=`[[*ELEMENT-WorkIndex-Top10Featured]]` &tpl=`ELEMENT-2019Work-Grid-ProjecTpl` &depth=`0` &limit=`10` &includeTVs=`1` &processTVs=`1` &tvPrefix=`` &sortby=`RAND()` &includeTVList=`ELEMENT-2019Project-WorkIndexProjectBlurb,ELEMENT-2019Project-WorkIndexSelections,ELE-2019Project-WorkIndexCoverIMG-ALL,ELE-2019Project-WorkIndexCoverIMG-EXPERTISE,ELE-2019Project-WorkIndexCoverIMG-EXPERTISE-CAT1,ELE-2019Project-WorkIndexCoverIMG-EXPERTISE-CAT2,ELE-2019Project-WorkIndexCoverIMG-EXPERTISE-CAT3,ELE-2019Project-WorkIndexCoverIMG-EXPERTISE-CAT4,ELE-2019Project-WorkIndexCoverIMG-EXPERTISE-CAT5,ELE-2019Project-WorkIndexCoverIMG-INDUSTRY,ELE-2019Project-WorkIndexCoverIMG-INDUSTRY-CAT1,ELE-2019Project-WorkIndexCoverIMG-INDUSTRY-CAT2,ELE-2019Project-WorkIndexCoverIMG-INDUSTRY-CAT3,ELE-2019Project-WorkIndexCoverIMG-INDUSTRY-CAT4,ELE-2019Project-WorkIndexCoverIMG-INDUSTRY-CAT5` &debug=`1` &where=`[{"ELEMENT-2019Project-WorkIndexSelections":"[[*id]]"},{"OR:ELEMENT-2019Project-WorkIndexSelections:LIKE":"%,[[*id]]"},{"OR:ELEMENT-2019Project-WorkIndexSelections:LIKE":"[[*id]],%"},{"OR:ELEMENT-2019Project-WorkIndexSelections:LIKE":"%,[[*id]],%"}]` ]]
[[!getResources? 
&resources=`[[*ELEMENT-WorkIndex-Top10Featured]]` 
&tpl=`ELEMENT-2019Work-Grid-ProjecTpl` 
&depth=`0` 
&limit=`10` 
&includeTVs=`1` 
&processTVs=`1` 
&tvPrefix=`` 
&sortby=`RAND()` 
&includeTVList=`ELEMENT-2019Project-WorkIndexProjectBlurb,ELEMENT-2019Project-WorkIndexSelections,ELE-2019Project-WorkIndexCoverIMG-ALL,ELE-2019Project-WorkIndexCoverIMG-EXPERTISE,ELE-2019Project-WorkIndexCoverIMG-EXPERTISE-CAT1,ELE-2019Project-WorkIndexCoverIMG-EXPERTISE-CAT2,ELE-2019Project-WorkIndexCoverIMG-EXPERTISE-CAT3,ELE-2019Project-WorkIndexCoverIMG-EXPERTISE-CAT4,ELE-2019Project-WorkIndexCoverIMG-EXPERTISE-CAT5,ELE-2019Project-WorkIndexCoverIMG-INDUSTRY,ELE-2019Project-WorkIndexCoverIMG-INDUSTRY-CAT1,ELE-2019Project-WorkIndexCoverIMG-INDUSTRY-CAT2,ELE-2019Project-WorkIndexCoverIMG-INDUSTRY-CAT3,ELE-2019Project-WorkIndexCoverIMG-INDUSTRY-CAT4,ELE-2019Project-WorkIndexCoverIMG-INDUSTRY-CAT5` 
&debug=`1` 
&where=`[{"ELEMENT-2019Project-WorkIndexSelections":"[[*id]]"},{"OR:ELEMENT-2019Project-WorkIndexSelections:LIKE":"%,[[*id]]"},{"OR:ELEMENT-2019Project-WorkIndexSelections:LIKE":"[[*id]],%"},{"OR:ELEMENT-2019Project-WorkIndexSelections:LIKE":"%,[[*id]],%"}]` 

]]`

this editor hates backtics hahaha

ok just make it as small as possible
to get results, then add parameters.

1 Like

OK thanks - yes this editor is awful for adding in code!
That code still doesnt output anything… will take bits away and add back in to try and find the issue…

1 Like

maybe come to slack and pm me

1 Like

yes, backticks are a weakness. you can use three of them tho, the single ticks, above and below your code and that will preserve everything