Frage

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.

War es hilfreich?

Lösung 3

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.

Andere Tipps

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.

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/

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit sharepoint.stackexchange
scroll top