Dynamic
URLs using WildCard Module:
In
Sitecore, we have the option of creating Dynamic URLs. A Sitecore module called
Wildcard Module is being used to pass variables
instead of using Query String.
Multilingual
URLs with LinkManager:
Multilingual
URLs can be achieved in Sitecore using DisplayName for an item. To use
display name in URLs, we need to configure LinkManager to accept DisplayName.
Problem: Multilingual
URL is working perfectly in Sitecore. ItemResolver Pre-processor is able to
resolve the Sitecore item using Display Name. The real problem comes into
picture when we use wild card in multilingual URL (Display Name). Using Display
Name and wild card in Sitecore URL will returns “Item Not Found” page. This is
due to ItemResolver Processor in Sitecore doesn’t able to resolve the wild card
Sitecore item when using Display Name.
Resolution: To resolve this issue, we need to
modify ItemResolver processor. In processor, modify “GetChild” method to get the WildCard Item.
private Item
GetChild(Item item, string
itemName)
{
ChildList children = item.Children;
foreach (Item
item2 in children)
{
//Resolve WildCard Item in Multilingual URL.
//To Get WildCard Item (*)
if (item2.DisplayName == @"*" || item2.Name == @"*")
{
Item result = item2;
return result;
}
//Resolve WildCard Item in Multilingual URL.
if (item2.DisplayName.Equals(itemName, StringComparison.OrdinalIgnoreCase))
{
Item result = item2;
return result;
}
if (item2.Name.Equals(itemName, StringComparison.OrdinalIgnoreCase))
{
Item result = item2;
return
result;
}
}
return null;
}
Please comment if I am doing anything wrong.
Please comment if I am doing anything wrong.
Thanks!
ReplyDeleteThis might help others:
1. Use ILSpy to open 'Sitecore.Kernel.dll' and get the code from the original 'ItemResolver' class from the namespace 'Sitecore.Pipelines.HttpRequest'.
2. Copy it in your own project
3. Modify the method mentioned above
4. Change the '' for the ItemResolver in the web.config to obtain it from your own assembly