Pages

16 May, 2012

Sitecore Multilingual URLs/Dynamic URLs with Wildcard (Sitecore v6.5)

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.
blockquote { margin: 0; } blockquote p { padding: 15px; background: #eee; border-radius: 5px; } blockquote p::before { content: '\201C'; } blockquote p::after { content: '\201D'; }