Quantcast
Channel: C1 CMS Foundation - Open Source on .NET
Viewing all articles
Browse latest Browse all 2540

New Post: Trying to build a languagebar with CompositeC1SiteMapProvider

$
0
0
Hey out there
I have some trouble figure out, what i'm meaby doing wrong or if there is at bug :-)

My site have 2 Languages Danish and Greenlandic, as your can se in the code below, i'm asking for languages there is not current language.
(var cultures = provider.GetRootNodes().Where(n => n.Culture.Name != CultureInfo.CurrentCulture.Name).Select(n => n.Culture); )

When i asking the CompositeC1SiteMapProvider to FindSiteMapNodeFromKey, i'm getting current language
( var node = provider.FindSiteMapNodeFromKey(currentID, ci); )

Should'n i get a different language, so in this case i actully getting danish SiteMapNode on the danish site :-(
protected IEnumerable<CompositeC1SiteMapNode> GetLanguageNodes()
    {
        var currentID = SiteMap.CurrentNode.Key;
        var rootID = SiteMap.RootNode.Key;

        var provider = (CompositeC1SiteMapProvider)SiteMap.Provider;

        var cultures = provider.GetRootNodes().Where(n => n.Culture.Name != CultureInfo.CurrentCulture.Name).Select(n => n.Culture);

        foreach (var ci in cultures)
        {
            var node = provider.FindSiteMapNodeFromKey(currentID, ci);
            if (node == null)
            {
                node = provider.FindSiteMapNodeFromKey(rootID, ci);
            }

            yield return (CompositeC1SiteMapNode)node;
        }
    }

    protected string getLanguageName(CompositeC1SiteMapNode node)
    {
        switch (node.Culture.Name)
        {
            case "kl-GL": return "Kalaallisut";
            case "da-DK": return "Dansk";
        }

        return node.Culture.NativeName;
    }
I have searching around in Composite C1 source, but can't figure out what todo
http://compositec1.codeplex.com/SourceControl/changeset/view/23701#312877

As i understanding it, when i asking on FindSiteMapNodeFromKey(string key, CultureInfo culture)
Should'n i get a SiteMapNode in different languages then current ?

// Allan

Viewing all articles
Browse latest Browse all 2540

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>