This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
The following blog post is based on Slavo Ingilizov's blog post connected to custom URL formats for Sitefinity Content Modules. All hierarchical dynamic items in the Sitefinity CMS have URLs that are generated automatically from a given format. The default format includes the parent module item's name in the URL generated by hierarchical dynamic modules and item's title. The URL format of the hierarchical dynamic modules is configurable and this article explains how you can modify it.
The default structure of the hierarchical module items when one of them is opened in a browser is the following:
<---Page URL---><--Parent module item's URL--><--Item's URL name-->
Because there are two dynamic types in this case (Parent module and Child module), we can’t know if it specifies the URL of the parent module or the URL of the child module item. There is still a way to change the format in this case, but it involves some programming.public
class
CustomProvider : Telerik.Sitefinity.DynamicModules.Data.OpenAccessDynamicModuleProvider
{
int
temp = 0;
public
override
string
GetUrlFormat(Telerik.Sitefinity.GenericContent.Model.ILocatable item)
{
var resolvedItem = (DynamicContent)item;
Type typeChild = TypeResolutionService.ResolveType(
"Telerik.Sitefinity.DynamicTypes.Model.TestModule1.Testmodule2"
);
Type typeParent = TypeResolutionService.ResolveType(
"Telerik.Sitefinity.DynamicTypes.Model.TestModule1.Testmodule1"
);
var type = resolvedItem.GetType();
if
(typeChild == type)
{
temp = 1;
return
"/[UrlName]"
;
}
if
( temp > 0 )
{
if
(typeParent == type)
{
resolvedItem.SystemUrl =
""
;
return
""
;
}
}
return
"/[UrlName]"
;
}
}
To use your new provider, you need to register it in Sitefinity. To do this, follow these steps below:
Subscribe to get all the news, info and tutorials you need to build better business apps and sites