0

When adding a navigation node as like so:

foreach (SPNavigationNode node in web.Navigation.QuickLaunch)
{
    if (node.Title == "Parent Title")
    {
        SPNavigationNode newNode = new SPNavigationNode("Title I want", myList.DefaultViewUrl);
        node.Children.AddAsFirst(newNode);
    }
}

When the link is shown in quick launch it shows the name of myList as the title of the link instead of Title I want which was used in the SPNavigationNode constructor.

How do I get it to show Title I want instead?

0

you can use something like this

var node = web.Navigation.QuickLaunch[0];
string title = node.Title; 

SPNavigationSiteMapNode.UpdateSPNavigationNode(node
                    , null
                    , "NEW_TITLE"
                    , node.Url
                    , "DESCRIPTION"
                    , node.Properties["Target"].ToString()
                    , node.Properties["Audience"].ToString()
                    , true);
0

Just a possibility. If you have more than one language installed in your farm, you need to take into consideration the title resource property:

     SPList list = web.Lists.TryGetList("Announcements");
     if (list != null)
     {
       // Create a navigation node pointing to the Announcements list.
       SPNavigationNode newNode = new SPNavigationNode(list.Title, list.DefaultViewUrl);
       // Add the node to the Quick Launch area.
       SPNavigationNodeCollection quickLaunch = web.Navigation.QuickLaunch;
       quickLaunch.AddAsLast(newNode);

       // Copy translations of the list's title to the user resource for the node's title.
       string localizedTitle;
       foreach (CultureInfo culture in web.SupportedUICultures)
       {
          localizedTitle = list.TitleResource.GetValueForUICulture(culture);
          newNode.TitleResource.SetValueForUICulture(culture, localizedTitle);
       }
       newNode.Update();
     }

In your case, if your current culture is en-US, just try to check the following to see if this is the issue:

foreach (SPNavigationNode node in web.Navigation.QuickLaunch)
{
    if (node.Title == "Parent Title")
    {
        SPNavigationNode newNode = new SPNavigationNode("Title I want", myList.DefaultViewUrl);
        newNode.TitleResource.SetValueForUICulture("en-US","Title I want");
        node.Children.AddAsFirst(newNode);
    }
}
  • Thanks for the help @Xavi, unfortunately, the title still doesn't change with your implementation. – KidBatman Aug 26 '15 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.