Friday, August 26, 2011

SharePoint 2010 PortalNavigation Class

Customizing global and left navigation of SharePoint sites is a common task. But some of the properties worked in SharePoint 2007 are now deprecated and no longer working. As a solution SharePoint 2010 PortalNavigation Class comes in handy.
SharePoint 2010 PortalNavigation Class represents navigation for portal pages and other portal navigation objects. The PortalNavigation type exposes the following members and all of them are Public properties.

  • AutomaticSortingMethod: Controls the property to use when automatically sorting navigation items owned by this site.
  • CurrentDynamicChildLimit: Controls the maximum number of "dynamic" child items to show beneath this site in current (left) navigation.
  • CurrentIncludePages: Controls whether publishing pages in this site will be automatically included in current navigation.
  • CurrentIncludeSubSites: Controls whether sub-sites of this site will be automatically included in its current navigation.
  • CurrentNavigationNodes: A collection of SPNavigationNode objects that get included in the current navigation of the associated site.
  • GlobalDynamicChildLimit: Controls the maximum number of "dynamic" child items to show beneath this site in global navigation.Dynamic children are sub-sites (represented by SPWeb objects) and publishing pages. The default value is 20. Setting the value to 0 removes the limit.
  • GlobalIncludePages: Controls whether publishing pages in this site will be automatically included in global navigation.
  • GlobalIncludeSubSites: Controls whether sub-sites of this site will be automatically included in its global navigation.
  • GlobalNavigationNodes: A collection of SPNavigationNode objects that get included in the global navigation of the associated site.
  • InheritCurrent: Controls whether the associated site should display its own current navigation or should use the current navigation of its parent.
  • InheritGlobal: Controls whether the associated site should display its own global navigation or whether it should use the global navigation of its parent.
  • OrderingMethod: Controls the ordering of navigation items owned by this site.
  • ShowSiblings: Controls whether this site should display its sibling items in the current navigation.
  • SortAscending: Sorts items in a portal navigation in ascending alphanumeric order.

This is how we use these properties in Site definitions. To control the navigation settings of the site you need to activate the ‘NavigationProperties’ feature and specify the properties that you want to apply to the site.

<WebFeatures>

...
...
<!–- Navigation properties for global and current navigation -–>
<Feature ID="541F5F57-C847-4e16-B59A-B31E90E6F9EA">
<Properties xmlns="http://schemas.microsoft.com/sharepoint/">
<Property Key="InheritGlobalNavigation" value="false" />
<Property Key="InheritCurrentNavigation" value="false" />
<Property Key="GlobalIncludeSubSites" value="true" />
<Property Key="GlobalIncludePages" value="true" />
<Property Key="CurrentIncludeSubSites" value="false" />
<Property Key="CurrentIncludePages" value="false" />
<Property Key="IncludeInGlobalNavigation" value="true" />
<Property Key="IncludeInCurrentNavigation" value="true" />
</Properties>
</Feature>
</WebFeatures>

PortalNavigation Class description and a code example to configures portal navigation for a specified site is available on MSDN here.

Thursday, August 11, 2011

Customize SharePoint List Forms in SP Designer

There are few ways to customize SharePoint List forms New (NewForm.aspx)/View (DispForm.aspx) and Edit (EditForm.aspx). In this post I will demonstrate how to customize Calendar list forms using SharePoint designer. Before any customizations Calendar list New form looks like this:



1. Go to the designer and open your SharePoint Site.

2. Select your Calendar list from Site Objects -> List and Libraries
.




3. Now we are in the View and Manage settings page of the list. Click on the “Forms” section on the right column to activate Forms ribbon menu item.




4. Here I’m going to customize the New Form. So select the “New Item Form” from the top ribbon. Specify a preferred File Name and tick “Set as default form for the selected type” option, if you want to make this form as the default.




5. Right Click on the new file created in the Forms section and select “Edit in Advanced Mode”.




6. You can find the XSL template called “dvt_1.rowedit”, which renders all the controls in the New Form.




7. Change controls as necessary. I’ll remove all the controls except for the Title, Location, Start Time and End Time.

8. Save the form after your changes. Select “Yes” in the warning dialog.

That is it. If you go to the SharePoint site and check New form you can see the changes.