6

I am working on SXA 1.2 along with sitecore 8.2 rev. 161129.

I am trying to build a search functionality using SXA toolbox controls. I tried adding a Filter(dropdown) control to the page, added a class to the facet field to fill this dropdown with certain items in a folder.

I added a class implementing ISimpleFacet which returns an array of strings (Item IDs), and the value of the "Field Name", was a single line text field that has a string value.

Unfortunately the dropdown is not filling any value.. it is still empty. Any idea what I might be missing?

following is the class written to get the items IDs:

public class ItemsFacet : ISimpleFacet
{  
    public string[] Filters()
    {
        return new string[2]
        {
            "1bfe1a9765d9451a9c77f9fc7210cb64",
            "c9b58de777584040be1af11253b56a2a"
        };
    }  
}

Thanks!

  • The Facet Filter field that is a Sitecore field, not an SXA one. We didn't modify that functionality in SXA and as far as I remember we never used that field. So there are two options: it's not working in Sitecore or SXA doesn't support custom implementation provided in Facet Filter field. I will try to check this durring incoming week. – Dawid Rutkowski Jul 2 '17 at 20:21
  • Any news regarding this? – joanelaydi Jul 23 '17 at 12:28
1

You don't need to create a ISimpleFacet class to get values in the drop-down, it is much simpler and can be achieved via CMS only. Assuming that you need to dropdown to filter down the results from broad search query, please do the following:

  1. Create your name/value pairs in a folder under the 'Data' section of your site, you can use 'Enums' folder and 'Enum' value templates or your own one.

  2. Add a 'droptree' field in your template that refers to the 'Enums' folder

  3. Create a 'Search Scope' for that the page/section, let say you want to search only news articles, under /sitecore/content/{your-site}/Settings/Scopes
  4. Create a 'List Facet' for that field under /sitecore/content/{your-site}/Settings/Facets

  5. Switch to experience editor mode for the search page, Drag & drop 'Dropdown' filter on the page and select the list facet within the 'Facet' field.

Save and publish and your dropdown values should be coming up.

  • can i change the sort order of the dropdown filter, it has only two options: sort by names and sort by count. can i for example sort by date? – AmiraElEwady May 30 '18 at 9:00
  • You can, you need to add additional facet for the date field that you want to use, for example 'Published Date' and then refer it in the sort filter. – Naveed Ahmad Jun 1 '18 at 20:39

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.