Sitefinity Custom Download List

.Net Add comments

Problem: create a file-download-list that you can filter by tag, category, or other criteria

Solution:

  1. create a library and upload your files to it
  2. categories and/or tag the files the way you want them to be filtered
  3. download the following sample code from the Telerik team:
    http://www.sitefinity.com/ClientsFiles/143126_customdownloadlist.zip
    (for more information on this download refer to Telerik’s forum)
  4. add the following customizations to the supplied sample in order to filter by tags or categories:

            if (filterByTag)
            {
                tagFilter = new List<ITag>();
                IList<ITag> alltags = this.manager.GetTags().OfType<ITag>().ToList();
                foreach (Guid g in FromTags)
                {
                    foreach (ITag t1 in alltags)
                    {
                        if (t1.ID.Equals(g)) { tagFilter.Add(t1); }
                    }
                }
            }
            if (filterByCategory)
            {
                categoryFilter = new List<ICategory>();
                IList<ICategory> allcats = this.manager.GetCategories().OfType<ICategory>().ToList();
                foreach (Guid g in FromCategories)
                {
                    foreach (ICategory c1 in allcats)
                    {
                        if (c1.ID.Equals(g)) { categoryFilter.Add(c1); }
                    }
                }
            }

now you have a custom download list that filters by Tags or Categories.

I have only tried this code on a Sitefinity 3.7 Standard site, I don’t know if it is compatible with other versions.

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in