protected string FormatUrl(int itemId) { if (ForumConfiguration.CombineUrlParams) { return(SiteRoot + "/Forums/ForumView.aspx?pageid=" + PageId.ToInvariantString() + "&f=" + ForumParameterParser.FormatCombinedParam(itemId, 1)); } return(SiteRoot + "/Forums/ForumView.aspx?pageid=" + PageId.ToInvariantString() + "&mid=" + ModuleId.ToInvariantString() + "&ItemID=" + itemId.ToInvariantString()); }
private void PopulateControls() { if (forum == null) { return; } Title = SiteUtils.FormatPageTitle(siteSettings, FormatTitle(forum)); heading.Text = forum.Title; litForumDescription.Text = forum.Description; divDescription.Visible = (forum.Description.Length > 0) && !displaySettings.ForumViewHideForumDescription; MetaDescription = string.Format(CultureInfo.InvariantCulture, ForumResources.ForumMetaDescriptionFormat, FormatTitle(forum)); if (Page.Header != null) { Literal link = new Literal(); link.ID = "forumurl"; string canonicalUrl; if (ForumConfiguration.CombineUrlParams) { canonicalUrl = SiteRoot + "/Forums/ForumView.aspx?pageid=" + PageId.ToInvariantString() + "&f=" + ForumParameterParser.FormatCombinedParam(forum.ItemId, pageNumber); } else { canonicalUrl = SiteRoot + "/Forums/ForumView.aspx?" + "ItemID=" + forum.ItemId.ToInvariantString() + "&mid=" + ModuleId.ToInvariantString() + "&pageid=" + PageId.ToInvariantString() + "&pagenumber=" + pageNumber.ToInvariantString(); } string nextUrl; if (ForumConfiguration.CombineUrlParams) { nextUrl = SiteRoot + "/Forums/ForumView.aspx?pageid=" + PageId.ToInvariantString() + "&f=" + ForumParameterParser.FormatCombinedParam(forum.ItemId, pageNumber + 1); } else { nextUrl = SiteRoot + "/Forums/ForumView.aspx?" + "ItemID=" + forum.ItemId.ToInvariantString() + "&mid=" + ModuleId.ToInvariantString() + "&pageid=" + PageId.ToInvariantString() + "&pagenumber=" + (pageNumber + 1).ToInvariantString(); } string previousUrl; if (ForumConfiguration.CombineUrlParams) { previousUrl = SiteRoot + "/Forums/ForumView.aspx?pageid=" + PageId.ToInvariantString() + "&f=" + ForumParameterParser.FormatCombinedParam(forum.ItemId, pageNumber - 1); } else { previousUrl = SiteRoot + "/Forums/ForumView.aspx?" + "ItemID=" + forum.ItemId.ToInvariantString() + "&mid=" + ModuleId.ToInvariantString() + "&pageid=" + PageId.ToInvariantString() + "&pagenumber=" + (pageNumber - 1).ToInvariantString(); } if (SiteUtils.IsSecureRequest() && (!CurrentPage.RequireSsl) && (!siteSettings.UseSslOnAllPages)) { if (WebConfigSettings.ForceHttpForCanonicalUrlsThatDontRequireSsl) { canonicalUrl = canonicalUrl.Replace("https:", "http:"); nextUrl = nextUrl.Replace("https:", "http:"); previousUrl = previousUrl.Replace("https:", "http:"); } } link.Text = "\n<link rel='canonical' href='" + canonicalUrl + "' />"; Page.Header.Controls.Add(link); Literal nextLink = new Literal(); nextLink.ID = "forumNextLink"; nextLink.Text = "\n<link rel='next' href='" + nextUrl + "' />"; Literal prevLink = new Literal(); prevLink.ID = "forumPrevLink"; prevLink.Text = "\n<link rel='prev' href='" + previousUrl + "' />"; if (forum.TotalPages > 1) { if (pageNumber == 1) // first page { Page.Header.Controls.Add(nextLink); } else if (pageNumber == forum.TotalPages) // last page { Page.Header.Controls.Add(prevLink); } else //other pages { Page.Header.Controls.Add(prevLink); Page.Header.Controls.Add(nextLink); } } } }