Section Search - query on list items

7 posts by 3 authors in: Forums > CMS Builder
Last Post: September 28, 2017   (RSS)

By JeffC - September 23, 2017

Apologies for jumping in on this thread with an unrelated question.

I have a client in Australia that is looking for a reputable host provider. He currently uses crazy domains whose service, in his experience is unreliable.  Toledoh, I notice you are in Australia, can you recommend anyone.

Sorry again for jumping in. I looked but I don't think you can send a direct message to other users on this forum, and assumed you would probably be following your own question!

Jeff

By Toledoh - September 23, 2017

Sure thing. Send me an email tim@toledoh.com.au. 

Cheers,

Tim (toledoh.com.au)

By Dave - September 28, 2017

Hi Tim, 

Under: CMS Setup > Section Editors > Your Section > Searching (tab)

You can create a multi-value pulldown by adding [] after the fieldname, eg: 

Label Text|fieldname[]|match

And I think you're right that "query" type searches should show as a text field.  Try this patch in: /lib/menus/default/list_functions.php

Search for: b_all and REMOVE the line in red: 

    if (preg_match("/\b_all_\b/i", $fieldsAsCSV)) { $fieldsAsCSV = __getAllSearchableFieldsAsCSV($schema); }
    if (!$searchType) { $searchType = 'query'; }

Then add the code in BLUE

    // figure out "displayAs" search field type
    if (!$displayAs) {
      $displayAs = 'textfield'; // default search field type

      if (count($fieldnames) == 1 && in_array($searchType, ['', 'match'])) { // if single field
        $fieldName   = $fieldnames[0];
        $fieldSchema = @$schema[ trim($fieldName, '[]') ];
        if      ($fieldName           == 'hidden')   { $displayAs = 'checkbox'; }
        else if ($fieldSchema['type'] == 'checkbox') { $displayAs = 'checkbox'; }
        else if ($fieldSchema['type'] == 'list')     { $displayAs = 'dropdown'; }
      }
    }

    //
    if (!$searchType) { $searchType = 'query'; }
    $searchRows[] = array($label, $fieldnames, $displayAs, $searchType);

Once you do that you should get a search field with this that allows you to do -not -this searches.

Label Text|fieldname|query

Let me know if that works for you!

Dave Edis - Senior Developer

interactivetools.com

By Toledoh - September 28, 2017

Thanks Dave.

That Multi-select works great.  I'll try the patch shortly.

Cheers,

Tim (toledoh.com.au)

By Toledoh - September 28, 2017

Hey Dave.

I think it's working, but as the "type" field is a list, the values are the num rather than the label...

Not urgent now, as the multi-select works.  But happy to keep going if your perfectionist side kicks in :)

Cheers,

Tim (toledoh.com.au)

By Dave - September 28, 2017

Hmm, yea that is the way they're stored.  We'd have to do some more work to be able to search on the labels.

Dave Edis - Senior Developer

interactivetools.com