We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31912 MODX Staff
    • 95 Posts
    I am trying to display a listing of projects on a services page – each project page has a projectServicesTags TV and the services page also has this TV. The TV is using the autoTag input render to keep it easy for the client to add a new service. The individual projects may have more than one service tagged but the individual service page only has one of the tags assigned to it. Hope that makes sense, let me know if I can clarify that.

    To get the projects to show up, I thought I had it working fine by adding a % before and after the filter – the filters are inserted by whatever the service document is tagged as, of which there will only be one.

    [[getResources? &tpl=`project-listing-txt` &parents=`4` &includeTVs=`1` &processTVs=`1` &tvPrefix=`0` &tvFilters=`projectServiceTags==%[[*projectServiceTags?]]%`]]

    The issue with this came up in the final review, they have two service pages that have the word "water" in – one is Water and the other is Wastewater. On the water page projects tagged with wastewater are also showing up. Any ideas or thoughts how I could circumvent this? Removing the initial % fixes it, however it prevents projects with multiple tags showing up on other services pages with the tag beyond the first one.

    Thanks!
    Dustin
      • 1778
      • 659 Posts
      Hello
      From http://rtfm.modx.com/display/ADDON/getResources

      tvFilters
      Delimited-list of TemplateVar values to filter resources by. Supports two delimiters and two value search formats. THe first delimeter || represents a logical OR and the primary grouping mechanism. Within each group you can provide a comma-delimited list of values. These values can be either tied to a specific TemplateVar by name, e.g. myTV==value, or just the value, indicating you are searching for the value in any TemplateVar tied to the Resource. An example would be &tvFilters=`filter2==one,filter1==bar%||filter1==foo` NOTE: filtering by values uses a LIKE query and % is considered a wildcard. NOTE: This only looks at the raw value set for specific Resource, i. e. there must be a value specifically set for the Resource and it is not evaluated.

      The filtering seems to use a LIKE query... So it finds "water" and "wastewater" (and waterpolo etc)... I think I saw somewhere in the forum how to alter this behavior but can’t remember where sad

      Cheers