protected void BindData() { try { string keywords = txtSearchTerm.Text.Trim(); if (!String.IsNullOrEmpty(keywords)) { //can be removed if (String.IsNullOrEmpty(keywords)) { throw new NopException(LocalizationManager.GetLocaleResourceString("Forum.SearchTermCouldNotBeEmpty")); } int searchTermMinimumLength = SettingManager.GetSettingValueInteger("Search.ForumSearchTermMinimumLength", 3); if (keywords.Length < searchTermMinimumLength) { throw new NopException(string.Format(LocalizationManager.GetLocaleResourceString("Forum.SearchTermMinimumLengthIsNCharacters"), searchTermMinimumLength)); } int totalRecords = 0; int pageSize = 10; if (ForumManager.SearchResultsPageSize > 0) { pageSize = ForumManager.SearchResultsPageSize; } var forumTopics = ForumManager.GetAllTopics(0, 0, keywords, true, pageSize, this.CurrentPageIndex, out totalRecords); if (forumTopics.Count > 0) { this.searchPager1.PageSize = pageSize; this.searchPager1.TotalRecords = totalRecords; this.searchPager1.PageIndex = this.CurrentPageIndex; this.searchPager2.PageSize = pageSize; this.searchPager2.TotalRecords = totalRecords; this.searchPager2.PageIndex = this.CurrentPageIndex; rptrSearchResults.DataSource = forumTopics; rptrSearchResults.DataBind(); } rptrSearchResults.Visible = (forumTopics.Count > 0); lblNoResults.Visible = !(rptrSearchResults.Visible); } else { rptrSearchResults.Visible = false; } } catch (Exception exc) { rptrSearchResults.Visible = false; lblError.Text = Server.HtmlEncode(exc.Message); } }
protected void BindData() { Forum forum = ForumManager.GetForumByID(this.ForumID); if (forum != null) { //hlNewTopic.Visible = ForumManager.IsUserAllowedToCreateTopic(NopContext.Current.User, forum); lblForumName.Text = Server.HtmlEncode(forum.Name); lblForumDescription.Text = Server.HtmlEncode(forum.Description); hlNewTopic.NavigateUrl = SEOHelper.GetNewForumTopicURL(forum.ForumID); int totalRecords = 0; int pageSize = 10; if (ForumManager.TopicsPageSize > 0) { pageSize = ForumManager.TopicsPageSize; } ForumTopicCollection forumTopics = ForumManager.GetAllTopics(forum.ForumID, 0, string.Empty, false, pageSize, this.CurrentPageIndex, out totalRecords); if (forumTopics.Count > 0) { this.topicsPager1.PageSize = pageSize; this.topicsPager1.TotalRecords = totalRecords; this.topicsPager1.PageIndex = this.CurrentPageIndex; this.topicsPager2.PageSize = pageSize; this.topicsPager2.TotalRecords = totalRecords; this.topicsPager2.PageIndex = this.CurrentPageIndex; rptrTopics.DataSource = forumTopics; rptrTopics.DataBind(); } //subsciption if (ForumManager.IsUserAllowedToSubscribe(NopContext.Current.User)) { ForumSubscription forumSubscription = ForumManager.GetAllSubscriptions(NopContext.Current.User.CustomerID, forum.ForumID, 0, 1, 0).FirstOrDefault(); if (forumSubscription == null) { btnWatchForum.Text = GetLocaleResourceString("Forum.WatchForum"); } else { btnWatchForum.Text = GetLocaleResourceString("Forum.UnwatchForum"); } } else { btnWatchForum.Visible = false; } } else { Response.Redirect(SEOHelper.GetForumMainURL()); } }
protected void BindData() { try { string keywords = txtSearchTerm.Text.Trim(); if (!String.IsNullOrEmpty(keywords)) { //can be removed if (String.IsNullOrEmpty(keywords)) { throw new NopException(LocalizationManager.GetLocaleResourceString("Forum.SearchTermCouldNotBeEmpty")); } int searchTermMinimumLength = SettingManager.GetSettingValueInteger("Search.ForumSearchTermMinimumLength", 3); if (keywords.Length < searchTermMinimumLength) { throw new NopException(string.Format(LocalizationManager.GetLocaleResourceString("Forum.SearchTermMinimumLengthIsNCharacters"), searchTermMinimumLength)); } int forumId = 0; ForumSearchTypeEnum searchWithin = 0; int limitResultsToPrevious = 0; if (cbAdvancedSearch.Checked) { //adv search forumId = ctrlForumSelector.SelectedForumId; searchWithin = (ForumSearchTypeEnum)Convert.ToInt32(ddlSearchWithin.SelectedValue); limitResultsToPrevious = Convert.ToInt32(ddlLimitResultsToPrevious.SelectedValue); } int totalRecords = 0; int pageSize = 10; if (ForumManager.SearchResultsPageSize > 0) { pageSize = ForumManager.SearchResultsPageSize; } var forumTopics = ForumManager.GetAllTopics(forumId, 0, keywords, searchWithin, limitResultsToPrevious, pageSize, this.CurrentPageIndex, out totalRecords); if (forumTopics.Count > 0) { this.searchPager1.PageSize = pageSize; this.searchPager1.TotalRecords = totalRecords; this.searchPager1.PageIndex = this.CurrentPageIndex; this.searchPager2.PageSize = pageSize; this.searchPager2.TotalRecords = totalRecords; this.searchPager2.PageIndex = this.CurrentPageIndex; rptrSearchResults.DataSource = forumTopics; rptrSearchResults.DataBind(); } rptrSearchResults.Visible = (forumTopics.Count > 0); lblNoResults.Visible = !(rptrSearchResults.Visible); } else { rptrSearchResults.Visible = false; } } catch (Exception exc) { rptrSearchResults.Visible = false; lblError.Text = Server.HtmlEncode(exc.Message); } }