We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12151
    • 115 Posts
    hi there, how can i make a ditto filter case insensitive?

    eg:
    the longtitle of a document is "Homer Simpson"
    the filter param could be `longtitle,homer,7` based on the user input

    how can i make the comparison case insensitive as the above returns no results, whereas `longtitle,Homer,7` returns the correct data

    thanks smiley
      • 12151
      • 115 Posts
      SOLVED

      To make a filter search case insensitive i added the following code to filter.class.inc.php (Ditto2) at line 88:

      case 9 : // case insenstive version of #7 - exclude records that do not contain the text of the criterion
      	if (strpos(strtolower($value[$this->array_key]), strtolower($this->filterValue))===FALSE)
      		$unset = 0;
      	break;
      case 10 : // case insenstive version of #8 - exclude records that do contain the text of the criterion
      	if (strpos(strtolower($value[$this->array_key]), strtolower($this->filterValue))!==FALSE)
      		$unset = 0;
      	break;	

      USAGE: &filter=`field,string,9`

      i also had another filter problem - to search lastnames of people in the database but by the first character only. i could not find a way to do this with "out-of-the-box" ditto so i added the following code to filter.class.inc.php:

      case 11 : // checks leading character of the field
      	$firstChr = strtoupper(substr($value[$this->array_key], 0, 1));
      	if ($firstChr!=$this->filterValue)
      		$unset = 0;
      	break;

      USAGE: &filter=`field,character,11`

      i hope this helps anyone, or if there’s a better way please enlighten me! smiley
        • 18397
        • 3,250 Posts
        Please file a ticket for this. Thanks.