Skip to content

Instantly share code, notes, and snippets.

/Filter.ascx.cs Secret

Created January 14, 2017 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/28e4326ba0ceb74dca1db3bdf56e6ba3 to your computer and use it in GitHub Desktop.
Save anonymous/28e4326ba0ceb74dca1db3bdf56e6ba3 to your computer and use it in GitHub Desktop.
using CMS.DocumentEngine.Web.UI;
using CMS.Helpers;
using CMS.Taxonomy;
using System;
using System.Web.UI.WebControls;
public partial class CMSWebParts_MySite_Filters_Filter : CMSAbstractDataFilterControl
{
protected override void OnInit(EventArgs e)
{
SetupControl();
base.OnInit(e);
}
protected override void OnPreRender(EventArgs e)
{
SetFilter();
base.OnPreRender(e);
}
private void SetupControl()
{
if (this.StopProcessing)
{
this.Visible = false;
}
else if (!RequestHelper.IsPostBack())
{
InitializeCategories();
}
}
private void InitializeCategories()
{
CategoryInfo parent = CategoryInfoProvider.GetCategoryInfo("MyCategory", CurrentSite.SiteName);
var categories = CategoryInfoProvider.GetChildCategories(parent.CategoryID, null, "CategoryOrder ASC", 0, "CategoryDisplayName, CategoryID", CurrentSite.SiteID).Execute();
if (!DataHelper.DataSourceIsEmpty(categories))
{
this.ddlCategories.DataSource = categories;
this.ddlCategories.DataTextField = "CategoryDisplayName";
this.ddlCategories.DataValueField = "CategoryID";
this.ddlCategories.DataBind();
this.ddlCategories.Items.Insert(0, new ListItem("Any Category", ""));
}
}
// SetFilter and other methods removed for brevity
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment