How to show the correct taxonomy management in SharePoint 2010 EditModePanel?

We have our own type of content in our SharePoint 2010 build that includes the Managed Metadata field for keywords.

The field seems to be expanded OK, because if I edit the item in the list it is in, I get the correct taxonomy selection control and my conditions are retrieved from the term store.

Nonetheless; we use the EditModePanel on the Layout page for the item to allow in-place editing of the objects, and I cannot get the correct taxonomy selection control.

If I add TaxonomyWebTaggingControl to the page layout and hardcode SSPId etc., then it will work;

<TaxonomyControls:TaxonomyWebTaggingControl runat="server" SSPId="234234-234234-34341-343" TermSetId="234234-23342-34234-234-234"/>

However, we cannot hard code the values, since the term repository will be created when the client deploys the site.

When we create a content type, we have an event receiver that binds the field to the correct storage / term set using their names, but I don’t understand how to get the field in EditModePanel to get / set them.

What I really want is something like:

<TaxonomyControls:TaxonomyWebTaggingControl runat="server" TermStore="My term store name" TermSet="Keywords"/>

Did I miss something?

My event receiver is as follows:

 try
        {
            SPSite site = ((SPWeb)properties.Feature.Parent).Site as SPSite;

            Guid fieldId = new Guid("3211B052-5332-424C-A066-BBE21AEAB878");
            if (site.RootWeb.Fields.Contains(fieldId))
            {
                TaxonomySession session = new TaxonomySession(site);

                if (session.TermStores.Count != 0)
                {
                    var termStore = session.TermStores["Managed Metadata Service"];
                    var group = termStore.Groups.GetByName("My Client");
                    var termSet = group.TermSets["Keywords"];

                    TaxonomyField field = site.RootWeb.Fields[fieldId] as TaxonomyField;

                    field.SspId = termSet.TermStore.Id;
                    field.TermSetId = termSet.Id;
                    field.AnchorId = Guid.Empty;
                    field.AllowMultipleValues = true;
                    field.TextField = fieldId;
                    field.TextField = new Guid("{574C5BCE-74E8-40C8-BE90-C9338135D491}");
                    field.Update();
                    Log.Logger.LogEvent("ContentType Activation", "Updated keywords field with MMS details");
                }
            }
        }
        catch (Exception ex)
        {
            Log.Logger.LogException(ex, "Content Type Activation", ex.Message);
        }
+3
source share
1 answer

To do this, you should use TaxonomyFieldControl:

<%@ Register Tagprefix="Taxonomy" Namespace="Microsoft.SharePoint.Taxonomy" Assembly="Microsoft.SharePoint.Taxonomy, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<Taxonomy:TaxonomyFieldControl FieldName="My Field Name" runat="server" id="myField"/>

+3
source

Source: https://habr.com/ru/post/1791227/


All Articles