Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SiteMapNode attribute localization always returns null #339

Closed
halyburton opened this issue Jul 30, 2014 · 1 comment
Closed

SiteMapNode attribute localization always returns null #339

halyburton opened this issue Jul 30, 2014 · 1 comment

Comments

@halyburton
Copy link

When using explicit localization only Title and Description attributes of a SiteMapNode are to localized properly. Any custom attributes return NULL.

Example SiteMapNode:

<mvcSiteMapNode controller="Home" action="Index" title="$resources:MainSitemap,HomeTitle" description="$resources:MainSitemap,HomeMetaDescription" metaKeywords="$resources:MainSitemap,HomeMetaKeywords" >

I am using my own HtmlHelper to write the keywords out to the view, but it always errors saying the value of metaKeywords is null.

public static MvcHtmlString MetaKeywords(this HtmlHelper helper)
{
    if (MvcSiteMapProvider.SiteMaps.Current != null && MvcSiteMapProvider.SiteMaps.Current.CurrentNode != null)
    {
        MvcSiteMapProvider.ISiteMapNode node = MvcSiteMapProvider.SiteMaps.Current.CurrentNode;
        if (node != null && node.Attributes.ContainsKey("metaKeywords") && node.Attributes["metaKeywords"] != null && !String.IsNullOrWhiteSpace(node.Attributes["metaKeywords"].ToString()))
        {
            return new MvcHtmlString(String.Format("<meta name=\"keywords\" content=\"{0}\" />", node.Attributes["metaKeywords"].ToString()));
        }
    }
    return new MvcHtmlString(string.Empty);
}

Not the cleanest code but i was trying to debug what was null.

I know that this is not the best way to handle Keywords or Description, but none the less, it looks like this is suppose to work and there is a problem fetching the resources for other attributes. I am updating from an older version where i used to use implicit localization and this worked, so this is kind a big issue for me.

Any help would be great. Thanks

@NightOwl888
Copy link
Collaborator

What version did this work in and what version did this not work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants