ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Search parameter and relationship fields

September 17, 2009 12:21am

Subscribe [2]
  • #1 / Sep 17, 2009 12:21am

    Jacob Fentress

    37 posts

    Concerning the weblog entries search parameter, the EE docs states:

    NOTE: Only custom fields of the type “Text Input”, “Textarea”, and “Drop-down Lists” are searched with this parameter.

    That’s not quite true. You can use the search parameter on a relationship field to find out if a relationship has been made or not. To do it, you do not use the IS_EMPTY constant because relationship fields are never saved as empty in the database. Relationship fields without relationships are saved in the database as “0”.

    So here’s is the parameter you need:

    search:my_relationship_field="=0"

    I hope that helps someone out.

  • #2 / Sep 17, 2009 10:39am

    Mark Bowen

    12637 posts

    Hi Jacob,

    Nice solution although I think more that what the documentation is trying to get at is that you can’t search for a certain word or value within a relationship field. All you could do here as you have shown is find any that are empty which isn’t quite the same thing. If you could search for a certain value within that field then that would be another thing 😉

    Best wishes,

    Mark

  • #3 / Sep 17, 2009 11:03am

    Jacob Fentress

    37 posts

    Absolutely. Actually searching the content of those fields would be fantastic.

    This was a nice find to solve a problem we ran up against in development, and I couldn’t find it documented anywhere, so I thought I’d share here.

    Thanks for the reply - I’m glad someone else found it interesting.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases