Search

I am creating a product inventory for a client, and I would like to be able to filter by multiple colors at once.

So far, I have it set up this way:

  1. A user selects colors (in the form of checkboxes) and submits the form, which redirects them to a new url, looking something like this:

    http://rh/inventory/?colors=blue,red

  2. The data source that pulls in the inventory is set up with the following filter:

    regexp:{$url-colors:}

I use the regex because what is submitted for the color field is usually more than just the color name; ie. 'Aprilia Black', rather than 'Black'.

The problem that I am running into is that with (for instance) {$url-colors} set to 'blue,red' the data source only brings in the entries that match 'blue', and not 'blue' OR 'red'. I have tried using filtering {$url-colors} without the regexp: flag, but this omits the lengthier titles as I mentioned above.

How can I do a regexp filter that will run for each comma-separated value in my {$url-colors} parameter? Or, how else could I set up the data source filter?

Thanks,

Chris

This might not be THE solution but:

(its a non regexp solution)

  1. Setup: I would have two sections - one for colors, and one for products.
  2. Product entries would have a Select Box Link field linked to the Colors section.
  3. With help of this field you would create associations between product and colors.
  4. Last, you could filter products by indexes of the colors (system id's), e.g. ?colors=1,22. {$url-colors} should be enough for the filter.

Hope this helps.

@ctruett
looks like you're overcomplicate the things. You can just use handle as value for filtering instead of exact color title. In this case 'Aprilia Black' becomes 'Aprilia-Black'. And comma separated filtering should work fine without regexp.

Thanks for the suggestions, guys.

What I ended up doing was adding a 'Search Color' select box field to my Inventory section, with choices that match the colors on the front end.

You can just use handle as value for filtering instead of exact color title.

Andrrr, can you elaborate on this statement? I think I understand what you mean, but I just want to be sure.

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