Last active
November 30, 2022 14:33
SF_10.1, SF_10.2, SF_11.0, SF_11.1, SF_11.2, SF_12.0, SF_12.1, SF_12.2, SF_13.0, SF_13.1, SF_13.2, SF_13.3, SF_14.0, SF_14.1, SF_14.2, SF_14.3 - https://docs.sitefinity.com/for-developers-change-the-url-format-of-hierarchical-dynamic-modules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Telerik.Sitefinity.DynamicModules.Model; | |
namespace SitefinityWebApp | |
{ | |
public class RemoveParentFromChildURLAllTypes : Telerik.Sitefinity.DynamicModules.Data.OpenAccessDynamicModuleProvider | |
{ | |
private bool resolvingChildUrlFormat = false; | |
/// <inheritdoc /> | |
public override string GetUrlFormat(Telerik.Sitefinity.GenericContent.Model.ILocatable item) | |
{ | |
string urlFormat = "/[UrlName]"; | |
var resolvedItem = (DynamicContent)item; | |
if (!this.resolvingChildUrlFormat && resolvedItem.SystemParentId != Guid.Empty) | |
{ | |
this.resolvingChildUrlFormat = true; | |
} | |
else if (this.resolvingChildUrlFormat) | |
{ | |
urlFormat = string.Empty; | |
if (resolvedItem.SystemParentId == Guid.Empty) | |
{ | |
// Stop child url format resolving when we reach the topmost parent | |
this.resolvingChildUrlFormat = false; | |
} | |
} | |
return urlFormat; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment