Allowing users to search and drill down on?content with exposed filters is a very useful feature of Views. ?And there are many many different ways to have users filter content on a page of your site.?Glossary filter is one very useful example. ?This filter allows the user to filter content by clicking a letter in the alphabet, and showing only the content that begins with the letter.
The Glossary?filter cannot be selected from?the Filter Criteria section of the views display edit page, and its setup requires a few steps. ?This blog post will walk through the?steps needed to create?a Glossary filter for your site. We assume?you have already created a view to list?your content.
Create an attachment display in your view:
- Create a new attachment of your view.
- Make sure it is attached to the page you want to filter.
- Attach the content either after or before the main content in your page view.
- Choose the display format for your?content (Content, Display Suite, or Fields).
- Sort the content by title in ascending order.
Create and configure the contextual filter:
- Add a contextual filter for ?Content: Title?.
- For the settings for when the filter is not available, set it to ?Display Summary'
- Set Sort Order for Ascending'.
- Set Sort By to ?Alphabetical'.
- Set the Format to ?Unformatted'.
- Under Exceptions set the value to ?all?, click the check box for ?Override Title? set that value to ?All? as well. ?Select the checkbox for ?Display items inline?.
- Enter the separator to be ?|?.
- For the settings when the filter is IS available, check the box for ?Specify validation criteria?.
- For Validator select the drop down for ?Basic validation?.
- For Action to take when the validator does not validate select ?Hide View? from the drop down.
- Under the MORE box, check the box for ?Glossary mode?.
- Set the Character limit to ?1?.
- Change the Case to ?Upper case?.
- Change the Case in path to ?Lower case?.
- Save the settings and the view.
Set up the contextual filter:
- Go to the page display the attachment display will link to.
- Add a contextual filter for ?Content:Title?.
- For when the filter is not in the URL, select the option for ?Display all results for the specified field'.
- For the settings when the filter is IS available, check the box for ?Specify validation criteria?.
- For Validator select the drop down for ?Basic validation?.
- For Action to take when the validator does not validate select ?Display contents of ?No results found?? from the drop down.
- Save the settings and the view.
You will?now be able to visit the page where the new Glossary filter will?be presented above the list of content.