-
-
Save anonymous/28e4326ba0ceb74dca1db3bdf56e6ba3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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