Skip to content
This repository was archived by the owner on Apr 7, 2024. It is now read-only.
This repository was archived by the owner on Apr 7, 2024. It is now read-only.

Issue with redirects pages when both language versions of a page are published directly after one another #75

Open
@themaf

Description

@themaf

Hi!

On our website we import content from another source regularly. When content is imported both language versions of the same page are automatically published back to back with very little time in between. We discovered that when this happens, a redirect-page is erroneously created for the first language version that was published.

In StaticWebInitialization, in the method OnPublishingContent, oldUrl is correct when the first, in our case Swedish, version of the page is published. But when the English version of the same page is published directly after, oldUrl becomes the url of the Swedish version of the page. Because of this, a redirect page is then created for the url to the Swedish page in OnPublishedContent.

We solved this issue on our site by including the language of the published content when getting oldUrl:

private void OnPublishingContent(object sender, ContentEventArgs e)
{
     var isPage = e.Content is PageData;
     if (isPage)
     {
          var content = e.Content as PageData;
          var staticWebService = ServiceLocator.Current.GetInstance<IStaticWebService>();

          var oldUrl = staticWebService.GetPageUrl(new ContentReference(e.Content.ContentLink.ID), content.Language);
          e.Items.Add("StaticWeb-OldUrl", oldUrl);
     }
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions