Feedback
 
Did this article resolve your question/issue?

   

Your feedback is appreciated.

Please tell us how we can make this article more useful. Please provide us a way to contact you, should we need clarification on the feedback provided or if you need further assistance.

Characters Remaining: 1025

 


Article

How to modify the entries in sitefinity sitemap using SitemapGeneratorBeforeWriting event

« Go Back

Information

 
Article Number000072906
EnvironmentProduct: Sitefinity
Version: 5.x, 6.x, 7.x, 8.x, 9.x, 10.x, 11.x, 12.x
OS: All supported OS versions
Database: All supported database servers
Question/Problem Description
How to modify the entries in sitefinity sitemap using SitemapGeneratorBeforeWriting event
Steps to Reproduce
Clarifying Information
Error Message
Defect/Enhancement Number
Cause
Resolution
Use the event ISitemapGeneratorBeforeWriting that is fired when the sitemap urls have been extracted from the DB and are to be written to sitemap.xml file.
The way to subscribe to this event is below:
 
protected void Application_Start(object sender, EventArgs e)
{
	Bootstrapper.Initialized += Bootstrapper_Initialized;
}

void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
{
	if (e.CommandName == "Bootstrapped")
	{
		EventHub.Subscribe<ISitemapGeneratorBeforeWriting>(evt => SitemapGeneratorBeforeWritingHandler(evt));
	}
}

void SitemapGeneratorBeforeWritingHandler(ISitemapGeneratorBeforeWriting evt)
{
	var entries = evt.Entries.ToList();

	// CRUD operations over the sitemap entries goes here (perform it over the "entries" collection)

    evt.Entries = entries;
}
Workaround
Notes
Attachment 
Last Modified Date6/14/2019 11:29 AM