3

I'm using Managed Metadata for navigation on a new site, and I've created a page to be used by the term set.

The content of the page is dynamic, thanks to the Items Matching a Tag web part.

However, I'd like to also set the title of the page, both in the <title> tag and at the top of the page above all the content, to be the current navigation tag.

What's the best way to do this? I'm assuming I need to modify the code for the page in SharePoint Designer, but I'm not really sure what I need to add, and where.

Updated

I've found a couple areas in the aspx that seem to control the areas I'm concerned about:

The title tag:

<asp:Content ContentPlaceHolderId="PlaceHolderPageTitle" runat="server">
    <SharePointWebControls:ListProperty Property="Title" runat="server"/> - 
    <SharePointWebControls:FieldValue FieldName="Title" runat="server"/>
</asp:Content>

The page title at the top:

<asp:Content ContentPlaceHolderId="PlaceHolderPageTitleInTitleArea" runat="server">
    <SharePointWebControls:FieldValue FieldName="Title" runat="server"/>
</asp:Content>

It seems to me that what I want to replace/change is <SharePointWebControls:FieldValue FieldName="Title" runat="server"/>. I'm having difficulty finding any documentation for how to access the current navigation term to put in that spot.

1

I don't think there is a way to automatically associate a navigational term to a title of any page. That is not OOTB. You could do some custom JavaScript to get the URL name after window() is ready and place that into the title element. Or you can manually set the title of the page in the SEO properties of that specific publishing page from the Ribbon.

  • The first option results in an error: Unknown server tag 'SharePoint:FieldValue', and the second snippet isn't in there. – Ben Wyatt Jan 29 '16 at 14:23
  • I'm editing in SharePoint Designer in advanced mode, logged in as the site collection administrator. – Ben Wyatt Jan 29 '16 at 14:47
  • No, I'm using the standard webpart page layout. Would I need to create a custom layout to accomplish what I'm trying to do here? – Ben Wyatt Jan 29 '16 at 15:01
  • I tried Robert's suggestion, but it's still just showing the name of the underlying page - not the navigation term. Looking at the comments on his post, Sharepoint: is just a shorthand prefix for SharePointWebControls, so this is actually the same thing that's already there. – Ben Wyatt Jan 29 '16 at 15:03
  • read my updated. – klewis Jan 29 '16 at 15:17
0

You can set the page title like so:

<asp:Content ContentPlaceholderID="PlaceHolderPageTitle" runat="server">    page title here | <SharePointWebControls:FieldValue ID="PageTitle" FieldName="Title" runat="server"/> </asp:Content>

As to adding your tags... This might point you in the right direction: http://www.sharepointconfig.com/2011/09/adding-managed-metadata-fields-to-sharepoint-publishing-pages/

  • This was actually one of the first things that blachawk suggested in their original answer, but they've edited it several times so you can't see that now. After going back and forth a bit, blachawk steered me toward custom page layouts, and I ended up finding the solution I wrote up in my answer. – Ben Wyatt Feb 1 '16 at 13:18
0

I've managed to get this working, using a custom page layout.

This MSDN page steered me to the changes I'd need to make, and with some modifications to their code, I have it working just the way I wanted.

First, this bit of code enabled me to put the navigation term directly into the <title> tag in the dynamic page, without any javascript.

<!--MS:<asp:ContentPlaceHolder id="PlaceHolderPageTitle" runat="server">-->
<!--CS: Start Taxonomy TermProperty Snippet-->
<!--SPM:<%@Register Tagprefix="Taxonomy"  Namespace="Microsoft.SharePoint.Taxonomy" Assembly="Microsoft.SharePoint.Taxonomy, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>-->
<!--MS:<Taxonomy:TermProperty Property="Name" runat="server">-->
<!--ME:</Taxonomy:TermProperty>-->
<!--ME:</asp:ContentPlaceHolder>-->

Then this bit allowed me to put the term into the "title" area on the page itself:

<!--MS:<asp:ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea" runat="server">-->
<!--SPM:<asp:SiteMapPath runat="server" ParentLevelsDisplayed="1" SiteMapProvider="CurrentNavigationSwitchableProvider"/>-->
<!--ME:</asp:ContentPlaceHolder>-->

By changing ParentLevelsDisplayed to 0, I was able to display the term on its own, without the parent navigation levels. It all looks completely native and natural now, exactly the way I wanted.

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.