0

I have a channel that displays artist information and they have an option to list their top three disciplines. Each discipline is listed in a separate field.

For example an artist could indicate the following disciplines:

  1. Photography
  2. Painting
  3. Pottery

Related to this I have a page for each discipline to show the artists which have selected that discipline. Currently I have it set to filter entries as follows:

search:first_discipline="photography"

The only problem here is that it doesn't show those artists that may have selected photography as their second or third discipline.

I tried combining multiple fields in the search parameter like this:

search:first_discipline|second_discipline|third_discipline="photography"

That appears to cancel out the filtering and brings back all entries. Is there a way to search all three fields?

Thanks!

  • 1
    I'm sorry, but why not to use the disciplines as categories? They're qualities, characteristics of the entries. – Robson Sobral Jun 4 '14 at 23:10
  • Hi Robson, no need to apologize. I have considered that as well, however, the users are selecting their disciplines via Channel Form and having three category fields seemed unwieldy. I am open to good solutions. – forrest Jun 5 '14 at 4:17
  • Well, I believe that for you to use the search, you should create just one field with three options. For me, to use three fields with the same info is clumsy. Did you try to use the channel form with three checkboxes? {categories}<input name="category[]" value="{category_id}"{if selected}checked="checked"{/if}>{category_name}{/categories}? I'm sorry, but I can't test this now. – Robson Sobral Jun 5 '14 at 11:53
0

I'm pretty sure you can use multiple search parameters, so just add 3 separate ones.

Having said that, Robson makes a good point that these items really belong in a single field. You could use categories or a custom field for this, and either should work fine in Channel Form.

| improve this answer | |
  • I appreciate both you and Robson's feedback. Here is the dilemma that prevents me from using just one field: each artist can select up to three disciplines that they work in, but they are not equally weighted. There is a primary, secondary and tertiary discipline. Hence the three fields and the limitation with using categories. I hope this makes it a little clearer what I am dealing with. – forrest Jun 5 '14 at 17:01
  • Also, on the three search parameters, the documentation indicates that using multiple search parameters means that all have to be true to return a value. – forrest Jun 5 '14 at 17:02
  • Wow, @fmz! Now, you choice makes sense to me. Using three fields goes to need a custom query, I guess, because of the "OR". --- You can use three category_groups, maybe. This will give you some flexibility, but... Now, to use categories looks like a strange solution to me. – Robson Sobral Jun 5 '14 at 19:28
  • Ah right I see. Are you already using Stash by any chance? If you're separating your data fetching code from your markup assembly code you could very easily just use Stash's match and against parameters to check against a Stashed data column that would contain all 3 fields. – James Smith Jun 6 '14 at 10:59
0

If you know the field id's for all three of your fields, you could do it the hard way and enable php on input

<?php
$ids = array();
$channels = ee()->db->select('entry_id')
        ->from('channel_data')
        ->where('field_id_1 = "photography" OR field_id_2 ="photography" OR field_id_3 = "photography" ')
        ->get();

if ($channels->num_rows() > 0)
{
    foreach($channels->result_array() as $row)
    {
        $ids[] = $row['entry_id'];
    }
}

$entry_ids = implode("|", $ids);
?>
{exp:channel:entries channel="foo" entry_id="<?php echo $entry_ids;?>"}
{title}<br/>
{/exp:channel:entries}
| improve this answer | |
0

A 3rd Party addon like SpolSpace's SuperSearch allows you to weight the value of fields in search results. You can even use relevance multipliers for certain situations. You can craft your own method of displaying the results.

You could do something like:

relevance="first_discipline=50+second_discipline=25+third_discipline=10"

Your first dicipline will be weighted first/heavier, but all 3 fields will be searched and results displayed.

http://www.solspace.com/docs/super_search/relevance_ordering/

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.