public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } if (IsPostBack) { return; } if (!Body.IsQueryExists("SeoMetaID")) { return; } var seoMetaId = Body.GetQueryInt("SeoMetaID"); var seoMetaInfo = DataProvider.SeoMetaDao.GetSeoMetaInfo(seoMetaId); if (seoMetaInfo == null) { return; } MetaName.Text = seoMetaInfo.SeoMetaName; MetaCode.Text = SeoManager.GetMetaContent(seoMetaInfo); }
private static void AddSeoMetaToContent(PageInfo pageInfo, StringBuilder contentBuilder) { if (IsSeoMetaExists(pageInfo)) { int seoMetaId; if (pageInfo.PageContentId != 0) { seoMetaId = DataProvider.SeoMetaDao.GetSeoMetaIdByNodeId(pageInfo.PageNodeId, false); if (seoMetaId == 0) { seoMetaId = DataProvider.SeoMetaDao.GetDefaultSeoMetaId(pageInfo.PublishmentSystemId); } } else { seoMetaId = DataProvider.SeoMetaDao.GetSeoMetaIdByNodeId(pageInfo.PageNodeId, true); if (seoMetaId == 0) { seoMetaId = DataProvider.SeoMetaDao.GetDefaultSeoMetaId(pageInfo.PublishmentSystemId); } } if (seoMetaId != 0) { var seoMetaInfo = DataProvider.SeoMetaDao.GetSeoMetaInfo(seoMetaId); var seoMetaInfoFromTemplate = SeoManager.GetSeoMetaInfo(contentBuilder.ToString()); if (!string.IsNullOrEmpty(seoMetaInfoFromTemplate.PageTitle)) { seoMetaInfo.PageTitle = string.Empty; } if (!string.IsNullOrEmpty(seoMetaInfoFromTemplate.Keywords)) { seoMetaInfo.Keywords = string.Empty; } if (!string.IsNullOrEmpty(seoMetaInfoFromTemplate.Description)) { seoMetaInfo.Description = string.Empty; } if (!string.IsNullOrEmpty(seoMetaInfoFromTemplate.Copyright)) { seoMetaInfo.Copyright = string.Empty; } if (!string.IsNullOrEmpty(seoMetaInfoFromTemplate.Author)) { seoMetaInfo.Author = string.Empty; } if (!string.IsNullOrEmpty(seoMetaInfoFromTemplate.Email)) { seoMetaInfo.Email = string.Empty; } if (!string.IsNullOrEmpty(seoMetaInfoFromTemplate.Language)) { seoMetaInfo.Language = string.Empty; } if (!string.IsNullOrEmpty(seoMetaInfoFromTemplate.Charset)) { seoMetaInfo.Charset = string.Empty; } if (!string.IsNullOrEmpty(seoMetaInfoFromTemplate.Distribution)) { seoMetaInfo.Distribution = string.Empty; } if (!string.IsNullOrEmpty(seoMetaInfoFromTemplate.Rating)) { seoMetaInfo.Rating = string.Empty; } if (!string.IsNullOrEmpty(seoMetaInfoFromTemplate.Robots)) { seoMetaInfo.Robots = string.Empty; } if (!string.IsNullOrEmpty(seoMetaInfoFromTemplate.RevisitAfter)) { seoMetaInfo.RevisitAfter = string.Empty; } if (!string.IsNullOrEmpty(seoMetaInfoFromTemplate.Expires)) { seoMetaInfo.Expires = string.Empty; } var metaContent = SeoManager.GetMetaContent(seoMetaInfo); if (!string.IsNullOrEmpty(metaContent)) { StringUtils.InsertBefore("</head>", contentBuilder, metaContent); } } } }