Searching by Agent Results in More Than Just One Agent’s Listings
By Matt Williams
Today, one of my colleagues asked me about an issue a customer brought up regarding shortcodes. They had created a List of Listings (aka static_listings) shortcode that was supposed to only show listings belonging to a specific agent. But for some reason listings for another agent at the same office were also coming up.
To create a shortcode, you can either run through the shortcode designer which lets you define your filters via a GUI, or by entering them directly on the page you intend to use it on. So rather than creating a static_listings shortcode and selecting the right filters, I can use syntax like this:
[static_listings context='twentyeleven' sort_by_options='cur_data.baths,cur_data.beds' sort_by='cur_data.beds' query_limit='10'] [pl_filter group='rets' filter='aid' value='123_4'] [/static_listings]
This shortcode does a List of Listings and you would think only the listings belonging to the agent with an ID of 123_4 should come up. But in this office, the agent had a colleague with an ID of 123_45 (these aren’t the actual ID’s). The other listings on the list belonged to that agent.
The reason this is happening is that the aid field, as with most other fields, is searched on using a ‘like’ search. So anything that has 123_4 in it will match. To change this to be an equals search instead of a like, just add a new pl_filter argument setting aid_match to eq:
[static_listings context='twentyeleven' sort_by_options='cur_data.baths,cur_data.beds' sort_by='cur_data.beds' query_limit='10'] [pl_filter group='rets' filter='aid' value='123_4'] [pl_filter group='rets' filter='aid_match' value='eq'] [/static_listings]
You can add ‘_match’ to any field in your feed and set the value to eq to do an exact search, ‘like’ to do a like search, or ‘ne’ to do a not equal search. But note that you cannot combine match types. So you can do like this and not equal to that.
Published on March 11, 2014
Written by Matt Williams
I am all about getting developers excited and efficient at using the Placester platform. To achieve this, I write blog posts, film videos, create code samples, and answer all of the more technical questions that come in our our support lines. Before joining the team at Placester, I held similar roles at Yottaa, Open Text, Microsoft, along with consulting roles at Oracle, Sun, Intel, IBM, and many others.