Showing posts with label Navigation. Show all posts
Showing posts with label Navigation. Show all posts

Table of contents web part remove max 50 limit

We use the "Table of contents" web part on SharePoint landing pages to give access to users to easily navigate to the sites/pages. But, there is a default limitation on the display items in left navigation or table of web part contents  in sharepoint. By default it shows only 50. If you have more than 50 items [either  sub sites or pages] in a site then it will not show up. To increase the limit or to remove limit, please do below changes.
  1. Go to the web.config of the SharePoint site through file system. Usually, it is located at "C:\inetpub\wwwroot\wss\virtualdirectories\port number".
  2.  Please take the back up of the web.config file before do any changes.
  3. Find the below tags in the web.config file.
    <add name="GlobalNavSiteMapProvider" description="CMS provider for Global navigation" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=13.0.0.0, Culture=neutral, PublicKeyToken=94de0004b6e3fcc5" NavigationType="Global" EncodeOutput="true" />
    <add name="CombinedNavSiteMapProvider" description="CMS provider for Combined navigation" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=13.0.0.0, Culture=neutral, PublicKeyToken=94de0004b6e3fcc5" NavigationType="Combined" EncodeOutput="true" />
    <add name="CurrentNavSiteMapProvider" description="CMS provider for Current navigation" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=13.0.0.0, Culture=neutral, PublicKeyToken=94de0004b6e3fcc5" NavigationType="Current" EncodeOutput="true" />
    <add name="CurrentNavSiteMapProviderNoEncode" description="CMS provider for Current navigation, no encoding of output" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=13.0.0.0, Culture=neutral, PublicKeyToken=94de0004b6e3fcc5" NavigationType="Current" EncodeOutput="false" />
  4. All the above tags are belongs to the navigation providers. They are the sources for the navigation controls. We can add any attributes which it recognizes to control the navigation.
  5. Now, according to our problem, we have to add an attribute which can control the number of items to display in navigation. The attribute is, "DynamicChildLimit".  Which accepts integer value. You can give any value in there to control navigation items. For example, if you give 20, then it will show you the top 20 items sorted by created. If you give 0, then it means no limit. Display how many items it has. 
  6. So, we have to add the attribute to all the above tags, so that it should looks like below.
    <add name="GlobalNavSiteMapProvider" description="CMS provider for Global navigation" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=13.0.0.0, Culture=neutral, PublicKeyToken=94de0004b6e3fcc5" NavigationType="Global" EncodeOutput="true" DynamicChildLimit="0" />
    <add name="CombinedNavSiteMapProvider" description="CMS provider for Combined navigation" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=13.0.0.0, Culture=neutral, PublicKeyToken=94de0004b6e3fcc5" NavigationType="Combined" EncodeOutput="true" DynamicChildLimit="0" />
    <add name="CurrentNavSiteMapProvider" description="CMS provider for Current navigation" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=13.0.0.0, Culture=neutral, PublicKeyToken=94de0004b6e3fcc5" NavigationType="Current" EncodeOutput="true" DynamicChildLimit="0" />
    <add name="CurrentNavSiteMapProviderNoEncode" description="CMS provider for Current navigation, no encoding of output" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=13.0.0.0, Culture=neutral, PublicKeyToken=94de0004b6e3fcc5" NavigationType="Current" EncodeOutput="false" DynamicChildLimit="0" />
Note: For removing the limit, I have used 0 in the above example. Please use the number according to your requirements.

Once you have changed the web.config file, save it and check the site. It should display the navigation items according to the setting you have given. Hope it helped. Read More...

How to display Site pages/ Subsites in navigation using Treeview control in sharepoint applicartion.

For very big projects in SharePoint or any other platform it's very difficult to organize the navigation to keep all the data on page. For example, you have plenty of data around 15 to 20 subsites and 50 pages, then it's impossible to display all the links at one place. So, it's big challenge that even you have more data on site but if user failed to find what he want on the site then it's just waste. So by thinking that for a long time, I came up with a good solution and here I am presenting for you with code.

What is my goal?
I want to show all the sites and pages in a SharePoint site in navigation area [lefft navigation] using asp tree view control in SharePoint.

Below is the complete code of the treeview functionality
In my case, we have 3 levels of data. So used tree view that has 3 levels.

ASPX Code:
Treeview control declaration and it's tree nodes 3 levels. We are writing some server side code to get and render the data as we want using different conditions. So for this purpose I am using prerender event of the tree view control.

<asp:TreeView ID="treeviewLeftNav" runat="server"
Width="191px" HoverNodeStyle-CssClass="leftNavHover"
DataSourceID="SiteMapDS" SelectedNodeStyle-CssClass="leftNavSelected"
OnPreRender="ControlTreeView_OnPreRender"
<LevelStyles>
<asp:TreeNodeStyle CssClass="leftNav1"></asp:TreeNodeStyle>
<asp:TreeNodeStyle CssClass="leftNav2"></asp:TreeNodeStyle>
<asp:TreeNodeStyle CssClass="leftNav3"></asp:TreeNodeStyle>
</LevelStyles>
</asp:TreeView>

We are using publishing site with all features enabled. So we are using PublishingNavigation control with PortalSiteMapDataSource to pull all pages and sites from SharePoint site.

<PublishingNavigation:PortalSiteMapDataSource ID="SiteMapDS" Runat="server"
SiteMapProvider="CurrentNavSiteMapProvider" EnableViewState="true"
StartingNodeOffset="0" ShowStartingNode="False"
TrimNonCurrentTypes="Heading"/>

In c#, I wrote below code for exact functionality of Expand/collapse TreeView.
C# code:
void ControlTreeView_OnPreRender(object sender, EventArgs e)
{
foreach(TreeNode n in treeviewLeftNav.Nodes)
{
if(n.NavigateUrl == Request.Url.AbsolutePath)
n.Expand();
else
{
if(treeviewLeftNav.SelectedNode!=null)
{
if(n!=treeviewLeftNav.SelectedNode.Parent)
{
if(n.ChildNodes.Count>0)
n.Collapse();
}
}
else
{
treeviewLeftNav.CollapseAll();
break;
}
}
RenderTreeNodes(n);
}

if(treeviewLeftNav.SelectedNode!=null)
treeviewLeftNav.SelectedNode.Expand();
}

void RenderTreeNodes(TreeNode node)
{
if(node!=null)
{
if(node.ChildNodes.Count>0)
{
foreach(TreeNode n in node.ChildNodes)
{
if(n.NavigateUrl == Request.Url.AbsolutePath)
{
n.Expand();
}
else
{
if(n!=treeviewLeftNav.SelectedNode.Parent)
n.Collapse();
else
n.Parent.Expand();
}
}
}
}
}
Note: please change your web.config of the site to allow server side code in pages where you are writing server side code. Read More...
Related Posts with Thumbnails
GiF Pictures, Images and Photos