/// <summary> /// Helper method to setup the pager /// </summary> private void SetupPager() { spPager.RecordCount = (int)this.TotalNumberOfResults; spPager.RecordsPerPage = ItemsPerPage; spPager.RecordsPerPageParamName = "pageunit"; spPager.CurrentPage = CurrentPage; spPager.PageParamName = "page"; spPager.ShowNumPages = 2; spPager.PagerStyleSettings.SelectedIndexCssClass = "pager-SelectedPage"; //"Serialize" OldKeywords to string if (OldKeywords.Count > 0) { spPager.BaseUrl = string.Format( "{0}?swKeyword={1}&old_keywords={2}", PageInstruction.GetUrl("PrettyUrl").UriStem, Server.UrlEncode(Keyword), Server.UrlEncode(OldKeywordsForQuery)); } else { spPager.BaseUrl = string.Format( "{0}?swKeyword={1}", PageInstruction.GetUrl("PrettyUrl").UriStem, Server.UrlEncode(Keyword)); } if (PageDisplayInformation.Language == DisplayLanguage.Spanish) { spPager.BaseUrl += "&lang=spanish"; } }
private void SetupFieldAndUrlFilters(ClinicalTrial trial) { // Copying the Title & Short Title logic from Advanced Form //set the page title as the protocol title PageInstruction.AddFieldFilter("long_title", (fieldName, data) => { data.Value = trial.BriefTitle; }); PageInstruction.AddFieldFilter("short_title", (fieldName, data) => { data.Value = trial.BriefTitle; //Eh, When would this happen??? if (!string.IsNullOrWhiteSpace(trial.NCTID)) { data.Value += " - " + trial.NCTID; } }); PageInstruction.AddFieldFilter("meta_description", (fieldname, data) => { data.Value = trial.BriefTitle; }); PageInstruction.AddUrlFilter("CurrentUrl", (name, url) => { //Copy the params //TODO: Really determine what to do with these params. If the search is invalid, we probably //hsould not show them all. foreach (KeyValuePair <string, string> param in this.ParsedReqUrlParams.QueryParameters) { url.QueryParameters.Add(param.Key, param.Value); } }); PageInstruction.AddUrlFilter("CanonicalUrl", (name, url) => { // only the id should be provided for the canonical URL, so clear all query parameters and // then add back id url.QueryParameters.Clear(); url.QueryParameters.Add("id", trial.NCIID); //url.QueryParameters.Add("id", TrialID); }); // Override the social media URL (og:url) PageInstruction.AddFieldFilter("og:url", (fieldName, data) => { //Ok, this is weird, but... The OpenGraph URL is actually a field. It kind of makes sense, //and it kind of does not. Really it should be a field that gets the og:url instead of the //pretty URL. //BUt here we are, and it is what we have. So let's replace the og:url with the canonical URL. data.Value = PageInstruction.GetUrl(NCI.Web.CDE.PageAssemblyInstructionUrls.CanonicalUrl).ToString(); }); }
protected virtual void SetupBlogPager(int recordsPerPage, int totalRecordCount, Dictionary <string, string> urlFilters) { BlogPager blogLandingPager = new BlogPager(); int currentPage = 0; string olderText = "< Older Posts"; string newerText = "Newer Posts >"; if (PageAssemblyContext.Current.PageAssemblyInstruction.GetField("Language") == "es") { olderText = "< Artículos anteriores"; newerText = "Artículos siguientes >"; } blogLandingPager.RecordCount = totalRecordCount; blogLandingPager.RecordsPerPage = recordsPerPage; if (string.IsNullOrEmpty(this.Page.Request.Params["page"])) { currentPage = 1; } else { currentPage = Int32.Parse(this.Page.Request.Params["page"]); } blogLandingPager.CurrentPage = currentPage; blogLandingPager.BaseUrl = PageInstruction.GetUrl(PageAssemblyInstructionUrls.PrettyUrl).ToString(); blogLandingPager.PageParamName = "page"; blogLandingPager.CssClass = "blog-pager clearfix"; blogLandingPager.PagerStyleSettings.NextPageCssClass = "older"; blogLandingPager.PagerStyleSettings.NextPageText = olderText; blogLandingPager.PagerStyleSettings.PrevPageCssClass = "newer"; blogLandingPager.PagerStyleSettings.PrevPageText = newerText; string searchQueryParams = string.Empty; if (this.SearchList.SearchType.ToLower() == "keyword" || this.SearchList.SearchType.ToLower() == "keyword_with_date") { searchQueryParams = "?keyword=" + Server.HtmlEncode(KeyWords); } if (this.SearchList.SearchType.ToLower() == "date" || this.SearchList.SearchType.ToLower() == "keyword_with_date") { if (string.IsNullOrEmpty(searchQueryParams)) { searchQueryParams = "?"; } else { searchQueryParams += "&"; } if (StartDate != DateTime.MinValue && EndDate != DateTime.MaxValue) { searchQueryParams += string.Format("startMonth={0}&startyear={1}&endMonth={2}&endYear={3}", StartDate.Month, StartDate.Year, EndDate.Month, EndDate.Year); } else { searchQueryParams += "startMonth=&startyear=&endMonth=&endYear="; } } foreach (KeyValuePair <string, string> entry in urlFilters) { if (string.IsNullOrEmpty(searchQueryParams)) { searchQueryParams = "?"; } else { searchQueryParams += "&"; } searchQueryParams += string.Format("filter[{0}]={1}", entry.Key, entry.Value); } blogLandingPager.BaseUrl += searchQueryParams; Controls.Add(blogLandingPager); // check for existence of previous and and next urls string prevUrl = blogLandingPager.GetPrevLinkUrl(); string nextUrl = blogLandingPager.GetNextLinkUrl(); if (prevUrl != null) { this.PageInstruction.AddUrlFilter("RelPrev", (name, url) => { url.SetUrl(prevUrl); }); } if (nextUrl != null) { this.PageInstruction.AddUrlFilter("RelNext", (name, url) => { url.SetUrl(nextUrl); }); } }
/// <summary> /// Helper method to setup the pager /// </summary> protected virtual void SetupPager(int recordsPerPage, int totalRecordCount, Dictionary <string, string> urlFilters) { SimplePager pager = new SimplePager(); pager.RecordCount = totalRecordCount; pager.RecordsPerPage = recordsPerPage; pager.CurrentPage = CurrentPage; pager.PageParamName = "page"; pager.PagerStyleSettings.SelectedIndexCssClass = "pager-SelectedPage"; pager.BaseUrl = PageInstruction.GetUrl(PageAssemblyInstructionUrls.PrettyUrl).ToString(); string searchQueryParams = string.Empty; if (this.SearchList.SearchType.ToLower() == "keyword" || this.SearchList.SearchType.ToLower() == "keyword_with_date") { searchQueryParams = "?keyword=" + Server.HtmlEncode(KeyWords); } if (this.SearchList.SearchType.ToLower() == "date" || this.SearchList.SearchType.ToLower() == "keyword_with_date") { if (string.IsNullOrEmpty(searchQueryParams)) { searchQueryParams = "?"; } else { searchQueryParams += "&"; } if (StartDate != DateTime.MinValue && EndDate != DateTime.MaxValue) { searchQueryParams += string.Format("startMonth={0}&startyear={1}&endMonth={2}&endYear={3}", StartDate.Month, StartDate.Year, EndDate.Month, EndDate.Year); } else { searchQueryParams += "startMonth=&startyear=&endMonth=&endYear="; } } foreach (KeyValuePair <string, string> entry in urlFilters) { if (string.IsNullOrEmpty(searchQueryParams)) { searchQueryParams = "?"; } else { searchQueryParams += "&"; } searchQueryParams += string.Format("filter[{0}]={1}", entry.Key, entry.Value); } pager.BaseUrl += searchQueryParams; Controls.Add(pager); // check for existence of previous and and next urls string prevUrl = pager.GetPrevLinkUrl(); string nextUrl = pager.GetNextLinkUrl(); if (prevUrl != null) { this.PageInstruction.AddUrlFilter("RelPrev", (name, url) => { url.SetUrl(prevUrl); }); } if (nextUrl != null) { this.PageInstruction.AddUrlFilter("RelNext", (name, url) => { url.SetUrl(nextUrl); }); } }