Search

If you use an expression like regexp:{$term} to filter a data source, make sure you don’t leave a space between the colon and the opening brace. If you do it will be appended to the front of $term. This will cause you to get no match in these examples:

  1. If $term = ‘this’ when searching ‘this string’.
  2. If $term = ‘ring’ when searching the same string.

I discovered this in 2.2. I haven’t checked to see if this applies to earlier versions.

Hm. Ad. 2.2 (trying to use the `regexp’ first time now)…

I am not sure whether I do something wrong, but I guess that if next expression works well

{$url-foo:$ds-prefered-foo}

then according to the documentation also next expression should work, right?

regexp: ^{$url-foo:$ds-prefered-foo}$

It does not work at all! Also the following simple

regexp: ^some_existing_foo

does not seem to produce any output from the DS. To be honest, I tried even the next expression:

regexp: .*

without any success… So I guess something may be broken around the regular expressions or do I do something wrong way?

I would like to use the `regexp’ feature to filter next rule:

{$url-foo:$ds-prefered-foo}+regexp: ^some_regexp$

which I guess is not possible (to combine `regexp’ with normal DS filtering)…

There is not much written about that. which is quite pity…

It might not solve your problem but it looks like you have a space between the colon (:) and the search term. Try taking that out. The purpose of this thread is to advise that a space will result in unexpected results.

which I guess is not possible (to combine `regexp’ with normal DS filtering)…

Try separating the two filters. You can have multiple filters on a field. The multiple filters will be applied as filter1 AND filter2.

I’ve never managed to get multiple filters on one field. It always fails down to the last filter entered for that field.

Just tested it and it doesn’t work, it fails as I’ve described. (Sym 2.1)

@designermonkey: I just combined multiple filters last night on my 2.1.2 install. Maybe the problem is specific to using multiple regular expressions? My filters were “Date later than 2009-12-31” and “Date earlier than 2011-01-01.”

Well, OK then. I suppose I just assumed that since you can filter on multiple fields that you would be able to filter on the same field multiple times. I’ll look into why this doesn’t work.

@jonasd - I tried “later than 2011-02-03 + earlier than 2011-02-06” on a date field and found that it does work. I tried a similar approach with regexp: on a text field and found that it does not work.

What I suggested above - and what dm pointed out will not work - is to add two separate filters to the DS for the same field. When the DS with two separate filters on the same field is saved it deletes the first and saves the second.

Hi.

I can not do any multiple filters in 2.2, honestly. It always falls back to one only. I thought it’s not bug but feature. Now I think, it’s very likely a bug somewhere…

@wisolman: I tried it with and without the whitespace with the same result…

I’ve looked a little closer at DS filtering and learned a few things about filtering a textarea field that I didn’t know, and that aren’t mentioned in the documentation. Filtering a textarea field is very different than filtering an input field - and this makes sense.

Input field: An exact match of the whole string is required to return a result. OR filtering (search strings separated by commas) works. AND filtering makes no sense in this case. Multiple (and different) search strings can’t exactly match any field value.

Textarea field: A match of a whole word is required to return a result. That is, if your search string is “alpha” all entries that contain the word “alpha” will be returned. The regexp: flag is not required. If your search string is “alpha bravo” (notice the space instead of a comma) all entries that contain either “alpha” or “bravo” (or both) will be returned. I could not get AND filtering to work. That is, I could not get it to return ONLY the entries that contain both “alpha” and “bravo”. In search terms separated by commas or pluses all but the first term is ignored.

@mjf: Could you please report this as a bug on the issue tracker.

You cannot have a regexp filter combined with a normal filter at the moment.

protected static function isFilterRegex($string){
    if(preg_match('/^regexp:/i', $string) || preg_match('/^not-?regexp:/i', $string)) return true;
}

The logic to implement is fairly extreme, and it would almost certainly break every extensions implementation (if any) of the regexp filter.

@wisolman The textarea field does not support AND operations in a typical manner as it uses FULLTEXT searching. Taken from the aforementioned link:

SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE);

If you tried to mimic this in Symphony, you couldn’t as the + would throw off the code and think it’s a typical AND operation.

If you need AND support today, the Textbox field offers it.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details