We have created an Episerver Find control and using custom checkbox categories we were hoping to Tag news articles with multiple categories. Using basic Episerver find c# code we have constructed something that works quite well apart from splitting up the multiple categories, it seems to display the multiple choices as one entry.
Is there any multi chice control that we should use that would allow us to categorise one page with multiple categories?
Find can certainly help you search for pages in on or several categories. It can also be used to retrieve a list of categories and count the number of pages in each using facets. Find however doesn't do much (anything really :-)) in terms of web forms controls, so perhaps you could post a bit more about what you are trying to achieve?
We are using a PropertyCheckboxlist control in the CMS which allows the user to select multiple categories for a News article. Of course. Episerver saves multiple selected items in a single string, such as "announcements,posts,greetings".
When using the Facets in Find it uses this one large string as a single Facet. So we thought about splitting the string up using the commas. This works ok if there are multiple selected items in the string and that each News articles have different results, but if two or more News articles have just a single Facet such as "announcements" or have duplicate strings Find distincts this into one single instance so our loop doesnt work how we want it to.
So, my question is how would we set up the CMS to allow the user to select multiple categories, obviously the PropertyCheckboxlist control is the wrong way to go about it. We had thought about using the existing Categories tab in the CMS but our client has hundreds of categories which are used across the entire site and the News section only has a selected few.
I hope this makes sense. It's quite difficult explaining what I need :).
Thanks for your patience
I'm not sure I follow you on this: "but if two or more News articles have just a single Facet such as "announcements" or have duplicate strings Find distincts this into one single instance so our loop doesnt work how we want it to." Any other way to describe it? :)
In general, if you have a property with string containing comma separated values I would add another, code only, property that splits it and returns a collection of strings, ie:
public IEnumerable<string> CategoriesList
if(Categories == null)
After re-indexing you can the retrieve a facet for categories using .TermsFacetFor(x => CategoriesList)
We have this working now but we have stumbled across something weird. We have 12 categories, all of which have been assigned to pages so we would expect to see all the categories in the facets area yet only 10 are showing. If we unassign one of the showing facets one of the hidden ones are shown.
Is there a limit to the number of facets shown on the page? If we do a count on the results it comes back with 76 TotalMatching yet when we loop the results it only shows ten.
Here is some of the code that we use:
query = query.Filter(x => x.LanguageID.Match("en-GB"));
var results = query.Select(x => new cSkills2S.Templates.PageTemplates.SearchResultHit
Title = !string.IsNullOrEmpty(x.PageName.AsHighlighted()) ? x.PageName.AsHighlighted() : x.PageName,
Url = x.LinkURL ?? x.LinkURL,
Description = !string.IsNullOrEmpty(x.Summary.AsHighlighted()) ? x.Summary.AsHighlighted() : x.Summary,
CategoryOut = ""
// .Skip((ActivePageNumber - 1) * PageSize)
If we do a TotalMatching count it shows 76:
ItemCount = results.TotalMatching;
If we do a simple loop it only shows 10:
foreach (var fct in results)
cou += 1;
Could you shine some light on this?
By default, 10 is the max size of number of facets. To increase this, you could do this:
TermsFacetFor(x => x.Something, facet => facet.Size = 50)
As for the results count, use .Take() to increase it to more than 10.http://find.episerver.com/Documentation/dotnet-api-pagination
That's amazing - many thanks for your help.