Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

In SharePoint 2013 when you create a new page under a publishing page it adds a new Term under the "site navigation" termset of the site collection. What I want to do, is having more control on where this term is created. I want to prevent it to be created directly under the "Site Navigation" termset, but under the site's term. I was wandering to create a feature to do it for me but I have two problems, 1. I dont know where I need to assign the navigation type and the friendly url. 2. How do I prevent SharePoint to do it for me.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

There are some options available for you under Site settings -> Navigation. For example, in the "Managed Navigation: Term Set" section, you can specify term set different from 'Site Navigation', and from now on your new pages will get terms in that term set. You can also uncheck "Create friendly URLs for new pages automatically" and "Add new pages to navigation automatically", and if you do that, no new terms will be created for new pages added by you in the Term Store.

Also, after a term is created, you can always move it to the required location using either Term Store manager or an object model. If you have too many terms, you can always write a piece of code (e.g. powershell script) to bulk move all the terms. This page has some information to help you get started http://msdn.microsoft.com/en-us/library/jj163949.aspx

In order to add new terms to navigation term set, you can use the following code:

    // Obtain navigation term set
    NavigationTermSet navigationTermSet = NavigationTermSet.GetAsResolvedByWeb(termSet, web, "GlobalNavigationTaxonomyProvider");
    // Specify that this term set can be used for site navigation
    navigationTermSet.IsNavigationTermSet = true;
    // Creates new term pointing to an already existing URL outside of SharePoint
    NavigationTerm term = navigationTermSet.CreateTerm("Bing Search", NavigationLinkType.SimpleLink, Guid.NewGuid());
    term.SimpleLinkUrl = "http://www.bing.com/";
    // Creates new term pointing to an existing SharePoint page
    NavigationTerm term2 = navigationTermSet.CreateTerm("Target page", NavigationLinkType.FriendlyUrl, Guid.NewGuid());
    term2.TargetUrl.Value = "~site/Pages/TargetPage.aspx";
share|improve this answer
    
yes, thanks for your answer. my question was wether I can do it programmatically. I couldn't find any property or method for term or termset objects. I had already seen this article but you cann't change url (or other properties) for the terms. –  Medes Feb 4 '13 at 20:51
    
So, what exactly do you want to be able to set programmatically? Do you need to add new terms with friendly URL to the term set that is used for site navigation? –  oldbam Feb 5 '13 at 22:55
    
yes, I can create terms but I didn't know how to set a friendly url to them. thank you, it was what I wanted. –  Medes Feb 7 '13 at 7:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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