Filter for exact ID value

edited January 2015 in Modules
I have 2 tables, one for IMAGES an one for PRODUCTS. I've set up a filter for my IMAGES list view that is populated by data from the PRODUCTS table (key=prod_id and value=prod_name). Each image in the IMAGES table is associated to it's corresponding product through a "corr_product_id" field. In other words, there can be many different images associated to the same product id.

If I select a "apple" with an id value of "25" from the filter dropdown, the list view will refresh and give me all images associated to the "apple" product (id 25), but also all of the images associated with the "orange" product (id 125), the "banana" product (id 250) and any other product that has 25 anywhere in its id number.

Is it possible to configure the filter to return only the exact matches (i.e. only the product with an id number of 25)?

Comments

  • edited 11:25AM
    If you add _equal to the filter key, that should do an exact match. If you look at the base_module_model.php file, there is a "_list_items_query" method that looks for different fields names (e.g. {field}_equal, {field}_from, {field}_fromequal...). So for example, if you change the filter from "id" to "id_equal", it should use an exact match instead of LIKE.
  • edited 11:25AM
    Exactly what I was looking for! Couldn't find it in the docs (though doesn't mean it isn't there). Thanks!
Sign In or Register to comment.