This is a migrated thread and some comments may be shown as answers.

How could I populate different sitemap base on the user culture language setting

1 Answer 69 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jack Ma
Top achievements
Rank 1
Jack Ma asked on 24 Apr 2010, 09:13 AM
Hi Heroes,
    I have a scenario that I want to populate different sitemap base on the user's culture setting. 
    i've tried 3 ways, 
    One is dynamically translate the sitemap node's title to the user's language, but in this method, I have to go through the sitemap nodes to achieve the translating job, and if the nodes level goes deep, this becomes terrible, at least not elegant.
    The other way I tried is, create different sitemap files for each supporting language, and populate the right sitemap base on the user culture setting dynamically, this sounds ideal, but unfortunately, the parameter set in the populatesitemapattribute must be a value parameter and I can not pass the culture setting to it something like  
  [PopulateSiteMap(SiteMapName = (string)System.Web.HttpContext.Current.Session["SiteMapName"], ViewDataKey = (string)System.Web.HttpContext.Current.Session["ViewDataKey"])] 
 public class AccountController : BaseController 
//.... 
it will hit compiler error. means you have to explicitely give things like SiteMapName="mysitemap", ViewDataKey="Eng"
     As can not pass the 'sitemapname' and 'viewdatakey' to the populatesitemapattribute dynamically(it's my supposed, maybe have another way can realize), I tried the 3rd way, I tried to combine all language sitemaps into one sitemap which is the default web.sitemap, and inside there I just create another level node to take the language setting at the title, and while i do populatesitemap, actually I'm using override populatesitemapattribute which give me a chance to finetune the sitemapnodes, and in there i just base on the sitemapnode's title whether equals the user's culture setting and populate the right nodes sitemap, but this process goes silly, at least i think so. The best things is I can dynamically choose the desired sitemap I registered in the sitemapdictionary as I like, either inside the populatesitemapattribute class or just pass the parameter to the SiteMapName and ViewDataKey parameter while assign the populatesitemapattribute to controllers. The later one I think is more elegant and simple. 

Does anybody have same scenario? Could you share your solutions on this?

Actually just on the go suffering this, I'm trying  to use sitemapmanager to choose the sitemap, but from the help document, I can not figure out how to select the sitemap, and I've tried use SiteMapManager.SiteMaps.TryGetvalue method, but failed to finish it, does anybody know how?

Appreciated your reply! 

Regards
Jack

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 26 Apr 2010, 10:56 PM
Hi Jack Ma,

The navigation components now supports the ability to bind directly to the sitemap registred into the SiteMapManager.SiteMaps collection. For more information please review this link.

Here you can download the SP1 of the Telerik Components for ASP.NET MVC, which supports the feature.

Sincerely yours,
Georgi Krustev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
General Discussions
Asked by
Jack Ma
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or