November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
You have a custom sitemap implementation and want to exclude som pages? Could you share some more of your code? From your controller, perhaps?
Something like this?
var sitemapContent = _contentRepository.GetDescendents(ContentReference.StartPage).Except(currentpage.ExcludePages);
Create a Class for example "SitemapPage" and Add ExcludePages property in this class.
Inherit all page types with the SitemapPage class.
To get all pages where ExcludePages is false
foreach (var site in _siteDefinitionrepository.List()) // If you have multi site
{
var startPage = site.StartPage;
if (ContentReference.IsNullOrEmpty(startPage)) { continue; }
var xmlSitemap = _contentRepository.GetChildren<SitemapPage>(startPage).FirstOrDefault(x => x.CheckPublishedStatus(PagePublishedStatus.Published) && !x. ExcludePages );
if (xmlSitemap == null) { continue; }
list.Add(xmlSitemap);
}
// create site map of pages in "list"
The code snippets provided by Tomas & Naveed are excellent examples. For sitemap logic, I have seen pages having a ExcludeFromSitemap boolean property instead of a list of pages to exclude (I guess) at the root level. That way you can filter at the page level with a predicate like :
GetDescendents().Where(x => !x.ExcludeFromSitemap)
Hi ,
In sitemap page i can include a excludeproperty to exclude pages to display in sitemap.
how to exclude those pages. below is my property.
[Display(
GroupName = SystemTabNames.Content,
Order = 2)]
[CultureSpecific]
[AllowedTypes(new Type[] { typeof(PageData) })]
public virtual IList<ContentReference> ExcludePages { get; set; }