Forums

[Plugin: Custom Field Template] cftsearch problem (3 posts)

  1. artmuns
    Member
    Posted 1 month ago #

    Hi,

    Great plugin and I have it working fine except for one problem. I have a key in a number of posts that has the option of three values to populate. They are "Yes", "No" and "Unknown". When searching for the value "No" the value "Unknown" is returned as well because (I believe) it contains the letters "no". The search page is here http://musiclibraryreport.com/library-search/search/. Any help is most appreciated.

    Thanks

    Art

  2. Hiroaki Miyashita
    Member
    Posted 1 month ago #

    It is a little bit complicated but you can resolve the trouble.

    First of all, you need to use the cftsearch shortcode with the format attribute like [cftsearch format=0] not just [cftsearch].

    There are several attributes for the search option. searchType is the type of the search fields. searchValue is the value of the search fields. The most important attribute for you is searchOperator. The default operator of the search SQL is LIKE '%blah%'. So it is impossible to distinguish no and unknown. You can change the operator. If you set = as the value of searchOperator, you can get the results you want. Please be careful that these values must be an array.

    Finally, you need to add the first array element of searchType,searchValue, and searchOperator in the cftsearch format. The first array element number is 1. In the cftsearch format, [keyname] will be converted to the default search field. It is same as [keyname][0]. If you set [keyname][1], the first search array element you set will be loaded.

    It is hard to explain the detail. It is the best way to see the example:

    Template Content: #0

    [keyname]
    type = select
    value = yes # no # unknown
    searchType = array('select');
    searchValue = array('yes # no # unknown');
    searchOperator = array('=');

    [cft] and [cftsearch] Shortcode Format]: #0

    keyname: [keyname][1]

    Please use the latest version of this plugin. Let me know if you have any questions. Thanks.

  3. artmuns
    Member
    Posted 2 weeks ago #

    Sorry not to get back to you sooner. Still wrestling with this and will let you know when I get a handle on it.

    Thanks for your help!

    Art

Reply

You must log in to post.

About this Topic