I have recently been building alot of new functionality in SharePoint 2013 and wanted to extend my Promoted Links WebPart to enable me to place the WebPart on a publishing website page layout and then have each page display a different set of links depending on which links in the list were tagged. I was able
to easily add a new managed metadata column which used the Managed Navigation Term set for the current site collection as its source so that I was able to select which page to display however I was unable how to change my WebPart to understand what the current pages term was. Having used the Content by Search WebPart I was aware that this has the functionality built so obviously it should be a fairly simple process.
I also know there is an OOTB WebPart called the Term Property WebPart which enables you to display properties based on a specific term or properties based upon the current context. Using this WebPart however would not be an option as there is no connection properties on this WebPart.
To find the solution I dug around the MSDN technical documentation for 2013 and came across the TaxonomyNavigationContext class (http://msdn.microsoft.com/en-gb/library/microsoft.sharepoint.publishing.navigation.taxonomynavigationcontext.aspx) This class was the answer to my problem, and by passing your current context you can easily get the information you need. e.g.
1 |
TaxonomyNavigationContext tnx = TaxonomyNavigationContext.Current; if (tnx.HasFriendlyUrl) { TermTitle = tnx.FriendlyUrlTerm.Title.ToString(); } |
One thing I discovered however is that the Root of the site does not necessarily have a term assigned to it so by checking if there is a friendly url before retrieving will prevent a null exception.
Thanks Man. did you had any luck in getting the URL of to Term ?
how to get friendly url using javascript
People asking how to get URL of the term:
currentTerm.get_localCustomProperties()[‘_Sys_Nav_SimpleLinkUrl’]
This will give you URL of the term
Chris,
I have same requirement to build navigation as you have done in http://www.ics.net/
The sub-navigation will lie in a bar under top navigation.. But yours is appearing on hover, however mine has to be fixed.. Do you have any ideas, or can you post your solution, I will figure out how to make it fixed myself
Any help will be appreciated..