Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author xnau webdesign

    (@xnau)

    Take a look at this article, which describes how to set that up.

    Customizing the List Search: Searching on Only One Field

    Thread Starter cjknowles17

    (@cjknowles17)

    xnau, I still can’t get it to work…

    I deleted:

    <?php
    /*
    * there are 4 options for this function which defines which fields will be
    * available in the search dropdown selector:
    * 1. “all fields” text: set the text of the default “all fields” item:
    * leave it “false” to use the internationalized default
    * 2. print it or return the element as a value: only use this if you
    * need to alter the HTML directly. You will need to print the item for
    * it to be seen. If ‘true’, the function prints the selector dropdown.
    * 3. columns: supply an array of column names if you want to define the
    * list of fields that can be used for searching: ‘false’ uses all displayed
    * fields
    * 4. sorting: you can choose to sort the list by ‘column’ (the order they
    * appear in the table), ‘alpha’ (alphabetical order), or ‘order’ which
    * uses the defined group/field order
    */
    $this->column_selector( false, true, false, ‘column’ );
    ?>

    And inserted:

    <input type=”hidden” name=”search_field” value=”company” />

    And I am still getting all the search fields. Anything else I have to edit?

    Could this also be used to allow only a certain number out of the total. For example, if I want to display a phone number, email address, first name, and last name, but I only want people to be able to search by the phone number OR email address, but not the first or last name, would this implementation work?

    Plugin Author xnau webdesign

    (@xnau)

    @cjknowles17 make sure you are setting up your custom template correctly, it sounds like your custom template isn’t getting used.

    @myreliefregistry Yes, read the comments in the pdb-list-detailed.php template…it’s argument 3 in the $this->column_selector method.

    Thread Starter cjknowles17

    (@cjknowles17)

    xnau, you are correct. I will read the documentation to do that. Thanks!

    Thread Starter cjknowles17

    (@cjknowles17)

    Alright, so I made the custom template (the detailed one), moved it where specified (into my child theme, created a template folder), and then made the changes (removing block off code for that html line).

    Now the search is just one field; however, no matter what I enter, it comes back with all the results still there.

    http://findcheapoil.com/listings/connecticut/

    I changed the “your_search_field_name” to “company”

    Plugin Author xnau webdesign

    (@xnau)

    OK, you can only do one of the two ways to modify the search form. Either use the dropdown with a defined list of fields OR use the hidden field and lose the dropdown altogether. You can’t use both.

    I would like hide the dropdown, but still let there be two search options. Is that possible? Users will know what the options are already.

    Also, in just the option for only letting some fields be available in the dropdown, how should the array be formatted in the argument. I tried a simple ’email, phone’ but that didn’t seen to do the trick.

    Plugin Author xnau webdesign

    (@xnau)

    It says “array” so that specifically means you need to put the argument in as an array:

    array('email','phone')

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Allow Only One Searchable Field?’ is closed to new replies.