We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27305
    • 173 Posts
    I have my meta data in a tv, and some other content that is not part of the page, how can I exclude some tv’s from the search? I know there is &filter parameter but can’t figure out how it works.

    Many thanks
    ss
      I made my first site with modx
      ------------------------
      Shopping blog
      Sky+ HD
      • 5811
      • 1,717 Posts
      by default AS do the search in document and tvs (&whereSearch=`content,tv`). By default all the values of the TVs are concatened to set up a field where the search occurs. So if you search "hihi" and "huhu" and these data are stored in two different Tvs, a search with the &advsearch=`allwords` will find the document.
      Unfortunately with the 1.8 you can’t specify exactly which tvs use to set up the concatened value for the tv. This is on my todo list wink

      Nevertheless you could exclude some documents if some TVs contains or not a specific value. For instance:
      &filter=`tv_content,any_text,7` excludes all the documents if at least one tv doesn’t contain the text "any_text"

      or

      &filter=`tv_content,any_text,8` excludes all the documents if at least one tv contains the text "any_text"

      But you could also use an other comparaison mode with the field tv_content:

      Exclude a document if its value in the specified field
      1 is not equal to the criterion (!=)
      2 is equal to the criterion (==)
      3 is less than the criterion (<)
      4 is greater than the criterion (>)
      5 is less than or equal to the criterion (<=)
      6 is greater than or equal to the criterion (>=)
      7 does not contain the text of the criterion
      8 does contain the text of the criterion
        • 27305
        • 173 Posts
        Thanks for the reply, does a template variable need the prefix tv_ or can I just enter its name? I tried what you said and get a modx error


          Error:  implode() [function.implode]: Bad arguments.   
          Error type/ Nr.:  Warning - 2   
          File:  /var/www/html/assets/snippets/ajaxSearch/classes/search.class.inc.php   
          Line:  938   
          Line 938 source:  $listIDs = implode(',',$filteredIDs);  


        my call is

        [!AjaxSearch? &ajaxSearch=`0` &AS_showForm=`0` &depth=`5` &addJscript=`0` &extract=`100` &grabMax=`10` &AS_showResults=`1` &advSearch=`allwords` &parents=`24,22,20,18,16,14,11,30,31,32,33,34,35,3` &whereSearch=`content,tv` &filter=`meta-description,any_text,7` !] 
          I made my first site with modx
          ------------------------
          Shopping blog
          Sky+ HD
          • 5811
          • 1,717 Posts
          &filter=`meta-description,any_text,7`
          No, the correct use of &filter is:
          &filter=`tv_content,xxxxxx,7`
          where:
          - tv_content is the name of the field with concatened value. Don’t change this name.
          - xxxxxx is the text you want search in any of your tvs
          - 7 is the comparaison code
            • 27305
            • 173 Posts
            I now have

            [!AjaxSearch? &ajaxSearch=`0` &AS_showForm=`0` &depth=`5` &addJscript=`0` &extract=`100` &grabMax=`10` &AS_showResults=`1` &advSearch=`allwords` &whereSearch=`content,tv` &filter=`tv_content,z_z,7`` !]


            none of my tv’s have z_z so it should filter out all the tv’s? but it shows them in the search
              I made my first site with modx
              ------------------------
              Shopping blog
              Sky+ HD