I was in a situation where I have to create a taxonomy bound site column for our SharePoint 2010 site. First I found it little difficult but SPCAMLEditor gave me a hand in figuring out the Taxonomy field structure in the SharePoint site. One Taxonomy field uses a set of two different fields to store the value.
When I need to create a SiteColumn named "TestColumn", a taxonomy column needs two different fields (TestColumn and TestColumn_0) for the field to work properly
TestColumn is of type "TaxonomyFieldType" and TestColumn_0 is of type "Note". The "TestColumn" references the TestColumn_0 in its field definition as a TextField.
I created the FieldDefinitions by copying the Schema xml to my project as a field definition xml file. When the field definition is deployed to a test server, the field is not saving any of the selected values. It allowed me to select the values but the values are not getting stored. After spending some time, I found that the Schema definition for the "TestColumn" references the ListId and WebId that it was created from in my local machine. Once I removed those references, it started working fine.
Hope this is helping some one else.
Senthil Subramanian
Monday, April 4, 2011
Tuesday, March 29, 2011
Adding SPNavigationNode to current navigation programatically in SPWebEventReceiver
When I provision a site using custom site template we may want to customize the Left navigation bar. I wanted to clear out all the navigation and have My own custom static links in newly created site.
As we know we can change the navigation using UI by customizing navigation under Site Settings > Navigation > Navigation Editing and Sorting. But I am trying to do it through programatically and was able to clear out all the navigation. When I try to create a new heading and save to the site navigation, it was failing to save it.
So the trick is to get the Publishing web using PublishingWeb.GetPublishingWeb(SPWeb) before adding the navigation nodes. If you get the PublishingWeb before customizing the navigation everything seems to be working fine.
PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
publishingWeb.Navigation.CurrentNavigationNodes.AddAsFirst(new SPNavigationNode("Some Text", properties.ServerRelativeUrl
+ "/Pages/media.aspx", false));
publishingWeb.Update();
And that did the trick to add a new navigation node with the above specified URL once the site is provisioned.
Refer this MSDN article for all sort of properties to modify navigation for a site. (http://msdn.microsoft.com/en-us/library/ee570519.aspx)
As we know we can change the navigation using UI by customizing navigation under Site Settings > Navigation > Navigation Editing and Sorting. But I am trying to do it through programatically and was able to clear out all the navigation. When I try to create a new heading and save to the site navigation, it was failing to save it.
So the trick is to get the Publishing web using PublishingWeb.GetPublishingWeb(SPWeb) before adding the navigation nodes. If you get the PublishingWeb before customizing the navigation everything seems to be working fine.
PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
publishingWeb.Navigation.CurrentNavigationNodes.AddAsFirst(new SPNavigationNode("Some Text", properties.ServerRelativeUrl
+ "/Pages/media.aspx", false));
publishingWeb.Update();
And that did the trick to add a new navigation node with the above specified URL once the site is provisioned.
Refer this MSDN article for all sort of properties to modify navigation for a site. (http://msdn.microsoft.com/en-us/library/ee570519.aspx)
Subscribe to:
Posts (Atom)
