0

I have a list of products with a filter in the side bar, which allows you to filter by size, country, etc. I want to be able to filter by product name in groups - 0-9, A-C, D-F, etc. The product name, as you can imagine, is contained the entry title.

My dynamic parameters are working fine when it is any other custom field, but not when it is the title (or url_title) that I am trying to filter on. I've even tried filtering by the exact product name, e.g. one of the products is "3 Fonteinen Oude Geuze", but still no luck.

Here's my code, just in case there is something obvious that I am doing wrong:

<form id="more-beer-sort" class="more-beer-sort" method="post" action="{path='{segment_1}'}">
  <label>
    Country:
    <select name="search:cf_more_country" id="search:cf_more_country">
      <option value="">All</option>
      {exp:query sql="SELECT DISTINCT field_id_48 AS cf_more_country FROM exp_channel_data WHERE channel_id=13"}
      <option value="{cf_more_country}">{cf_more_country}</option>
      {/exp:query}
    </select>
  </label>
  <label>
    Style:
    <select name="search:cf_more_style" id="search:cf_more_style">
      <option value="">All</option>
      {exp:query sql="SELECT DISTINCT field_id_49 AS cf_more_style FROM exp_channel_data WHERE channel_id=13"}
      <option value="{cf_more_style}">{cf_more_style}</option>
      {/exp:query}
    </select>
  </label>
  <label>
    Size:
    <select name="search:cf_more_size" id="search:cf_more_size">
      <option value="">All</option>
      {exp:query sql="SELECT DISTINCT field_id_54 AS cf_more_size FROM exp_channel_data WHERE channel_id=13"}
      {if cf_more_size!="Bottles|Draught"}
      <option value="{cf_more_size}">{cf_more_size}</option>
      {/if}
      {/exp:query}
    </select>
  </label>
  <label>
    Name:
    <select name="search:title" id="search:title">
      <option value="">All</option>
      <option value="0|1|2|3|4|5|6|7|8|9">0 - 9</option>
      <option value="A|B|C">A - C</option>
      <option value="D - F">D - F</option>
      <option value="G - I">G - I</option>
      <option value="J - L">J - L</option>
      <option value="M - O">M - O</option>
      <option value="P - R">P - R</option>
      <option value="S - U">S - U</option>
      <option value="V - Z">V - Z</option>
    </select>
  </label>
  <input type="submit" value="Filter List">
</form>

{exp:channel:entries channel="more" dynamic_parameters="search:cf_more_country|search:cf_more_style|search:cf_more_size|search:title" orderby="title" sort="asc" {sn_disable}}
  <!-- OUTPUT PRODUCTS -->
{/exp:channel:entries}

Note, I am using the query module to only show distinct/unique entries in the filter as per this post: Only show distinct entries

Thanks for any help or ideas of how to resolve this issue.

1

Looks like it should work at a quick glance. Since it seems that the Channel Search might not work with Title, I think your 2 options are create a new field for Product Name or you can write your own mysql query / plugin to do the search for you.

| improve this answer | |
  • Thanks for the reply. I was worried you'd suggest something like that. Probably a bit beyond my skills but I think a new field, as you suggest, may be the best option for me. I'm thinking a select field with the same options as what I have in my front-end filter, i.e. 0-9, a-c, e-f, etc. – Laura Montgomery Jul 22 '13 at 12:08

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.