We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21872
    • 95 Posts
    I have a tag based navigation. I have a template with a get resources snippet in it, it looks like this:
          
          [[!getResourcesTag?
          &elementClass=`modSnippet`
          &element=`getResources`
          &tpl=`simpleListing`
          &parents=`[[*id:notequal=`337,2`]]`
          &limit=`16`
          &includeContent=`1`
          &includeTVs=`1`
          &showHidden=`0`
          &hideContainers=`1`
          &cache=`1`
          &pageVarKey=`page`
          &toPlaceholder=`designGridPh`
          ]]


    Resource 334 uses this template. It has many tags, among them are (made up but analogous) "fluffy brown bunny" and "brown bunny"

    When the url is: [tt]http://www.mysite.com/path/to/resource334/?tag=brown+bunny&key=tags[/tt] I see resources tagged with both "fluffy brown bunny" and "brown bunny" when the url is: [tt]http://www.mysite.com/path/to/resource334/?tag=fluffy+brown+bunny&key=tags[/tt] I only see resources tagged with "fluffy brown bunny"

    I am using comma delimited tags, and my impression was that whitespace was valid within individual tags, so I’m not sure what is going on here. (preemptive trouble shooting: when I change parents to just [[*id]], it has no effect on this).
      • 22295
      • 153 Posts

      in the snippet call set &tagSearchType=`exact`
        • 21872
        • 95 Posts
        Well I feel dumb for overlooking that one. Thanks! That is too exact. I don’t want items that only have one tag, I need all items tagged with "brown bunnies", even if they are also tagged with "rodents" but not items tagged with "fluffy brown bunnies" unless they are tagged with both "fluffy brown bunnies" and "brown bunnies", which would never happen in the real use. Those should be distinct tags if the delimiter is a ’,’, shouldn’t they?

        update: Is the "&tagSearchType" parameter undocumented? Google shows zero results, http://www.google.com/search?q=%26tagSearchType+site:rtfm.modx.com/ and I couldn’t find it browsing, either.
          • 22295
          • 153 Posts
          look at getresourcestag.snippet

          if (!empty($_GET[$tagRequestParam])) {
              $tagSearchType = $modx->getOption('tagSearchType',$scriptProperties,'exact');
              if ($tagSearchType == 'contains') {
                  $scriptProperties['tvFilters'] = $tagKey.'==%'.$modx->stripTags(urldecode($_GET[$tagRequestParam])).'%';
              } else if ($tagSearchType == 'beginswith') {
                  $scriptProperties['tvFilters'] = $tagKey.'==%'.$modx->stripTags(urldecode($_GET[$tagRequestParam])).'';
              } else if ($tagSearchType == 'endswith') {
                  $scriptProperties['tvFilters'] = $tagKey.'=='.$modx->stripTags(urldecode($_GET[$tagRequestParam])).'%';
              } else {
                  $scriptProperties['tvFilters'] = $tagKey.'=='.$modx->stripTags(urldecode($_GET[$tagRequestParam])).'';
              }    
          }




          About multiple tags, that shouldn’t be too hard to do, but this feature is not available now. you can file a request at https://github.com/splittingred/tagLister/issues

          In the mean time - you can just call getResources directly with tvFilter (see getResources snippet for more info)
          syntax: &tvFilters=`filter2==one,filter1==bar%||filter1==foo`