[support] Views filter alphabetical range

toon severijns toon.severijns at gmail.com
Thu Aug 30 15:52:38 UTC 2012


Hello Ted,

The grouped filter suggestion was spot on. I've kept the computed field,
specified grouped filter values for it and brought them out using better
exposed filters.

Thanks again for the great help!


Best,


Toon


On Wed, Aug 22, 2012 at 11:49 PM, Ted <ted-drupalists at webfirst.com> wrote:

>  You can create a views-exposed-form--[view_id].tpl.php file for that
> view. Replace the text box with the HTML of your choice.
>
> Another possibility is to use taxonomy reference or list-type field, but
> you would have to write a hook_form_alter and associated functions to set
> the value of that field in a custom module. This would give you the radio
> buttons in the views filter with BEF.
>
> Actually, scratch all that. Here's the best option: update to the very
> latest Views, and then you can specify "Grouped filters". This lets you
> predefine regexes for the original text field exposed filter:
>
> Label: A-F, Operator: Regex, Value: ^[A-Fa-f]
> Label: G-L, etc....
>
> If you drop your computed field, this will make the query run a little
> slower (though you may not notice if it is not a lot of data). If instead
> you run this on the computed field, you can use the equals operator which
> will run faster (especially if you add an index to the table for your
> computed field).
>
> Ted
>
>
> On 8/22/2012 12:03 PM, toon severijns wrote:
>
> Thanks a lot Ted!
>
> I've followed your advise and i've got the computed field to work. I can't
> seem to bring out the computed field as radio buttons with better exposed
> filters though as it's a text field. Maybe facets could be a solution.
>
> Best,
>
>
> Toon
>
> On Tue, Aug 21, 2012 at 9:35 PM, Ted <ted-drupalists at webfirst.com> wrote:
>
>>
>> It might be easiest to use computed_field to store the appropriate range
>> value on the node. Then override the views-exposed-form.tpl.php if you need
>> the buttons to really be buttons. You could always get fancy with JS and
>> CSS using radio buttons and better_exposed_filters auto-submit. Facets
>> would work, but you would still need to use computed_field, I think Facet
>> API only supports ranges for numeric and date fields.
>>
>> Ted
>>
>>
>> On 8/21/2012 12:29 PM, toon severijns wrote:
>>
>> Hello,
>>
>> Could anybody help me with some advise on how to create a views filter
>> (D7) containing buttons with alphabetical ranges (like "A-F", "G-L", "M-R",
>> "S-Z", "All") filtering on the first letter of the nodes' title field?
>> I've seen a post on how to create an alphabetical index (
>> http://drupal.org/node/641342) but i kind of need the letters grouped in
>> ranges. Or is this something that's best done with search API/facets?
>>
>> Any help would be greatly appreciated!
>>
>> Best,
>>
>>
>> Toon
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20120830/667e44de/attachment.html 


More information about the support mailing list