Blog Archives

Change file Dependencies Limit in Master Page – the limit has exceeded.

If you  are getting following error:

The page ‘/_catalogs/masterpage/mymasterpage.master’ allows a limit of 11 direct dependencies, and the limit has exceeded.

You have 10 DirectFileDependencies on web.config, so you need change this value.

<SafeMode MaxControls=”200″ CallStack=”false” DirectFileDependencies=”10″ TotalFileDependencies=”50″ AllowPageLevelTrace=”false”>

Solution: 

<SafeMode MaxControls=”200″ CallStack=”false” DirectFileDependencies=”20” TotalFileDependencies=”50″ AllowPageLevelTrace=”false”>

MaxControls: This attribute limits the no of controls on the page. Default value 200.
DirectFileDependencies: This attribute limits the no of user controls added in master pages. Default value 10.
TotalFileDependencies: This attribute limits the no of controls added on the page (including Master page and page layout). Default value 50.

Actually doing changes in these value is not the best practice, but solved this issues!!!

Thanks

Advertisements

Script to Change Page Layout on Publishing Pages – PowerShell

If you want change pagelayouts, you can use this usefull script.

$spWeb = Get-SPWeb("http://fcsharepoint")
$pWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($spWeb)
$pSite = New-Object Microsoft.SharePoint.Publishing.PublishingSite($spWeb.Site);

$siteLayouts = $pSite.GetPageLayouts($false)
$myLayout = $siteLayouts["/_catalogs/masterpage/fcPageLayout.aspx"]
$query = New-Object Microsoft.SharePoint.SPQuery
$query.ViewAttributes = "Scope='RecursiveAll'"

$pages = $pWeb.GetPublishingPages($query)

foreach ($page in $pages)
{
     if ($page.ContentType.Name -eq "Folder")
     {
         continue
     } 
     $page.Layout = $myLayout
     $page.update()
     $page.ListItem.File.Publish("")
     $page.ListItem.File.Approve("")
}
$spWeb.Dispose()

SharePoint Foundation 2013 – Apply MasterPage on Site and SubSites – PowerShell Script

On SharePoint Foundation 2013 you can’t easily apply MasterPage on Subsites and Site because the Feature Site Publishing are not available.

So, if you what to do that, you can use powershell, using the script bellow:

SubSites: 

$site = Get-SPSite http://fcsharepoint:1000
$CustomMasterpage = "_catalogs/masterpage/CUSTOM.master"
foreach ($web in $site.AllWebs)
{
   $web.MasterUrl = $site.RootWeb.ServerRelativeUrl + $CustomMasterpage;
   $web.Update();
   $web.Dispose();
}

Creating Subsites using Powershell Script & List of SharePoint 2013 Template Sites

How to create a sub site using Power Shell scripts:

To add a new subsite use the New-SPWeb powershell command

New-SPWeb –url <new site url> -name <new site name> -template <template name>

Additional cmdlet which can be used: 

AddToTopNav: Add the site to the top navigation bar 

 UseParentTopNav: Use the top navigation bar from the parent

 AddToQuickLaunch: Add the new site to the Quick Launch section

– UniquePermissions: Break parent permissions, and will create for new Subsite.

Example:

$WebAppUrl="http://fcSharePoint:5000"

#->SubSite1<-
$SubSiteTitle1 = "This is SubSite  - 1 - Title"
$SubSite1Url = "SubSite1"
New-SPWeb –url $WebAppUrl"/"$SubSite1Url -name $SubSiteTitle1 -Template "STS#0" 
–AddToTopNav –UniquePermissions –UseParentTopNav
Write-Host 'Create new SubSite:' $SubSiteTitle1 '-> Url:'$WebAppUrl"/"$SubSite1Url

#->SubSite2<-
$SubSiteTitle2 = "This is SubSite - 2 - Title"
$SubSite2Url = "SubSite2"
New-SPWeb –url $WebAppUrl"/"$SubSite2Url -name $SubSiteTitle2 -Template "STS#0" 
–AddToTopNav –UniquePermissions –UseParentTopNav
Write-Host 'Create new SubSite:' $SubSiteTitle2 '-> Url:'$WebAppUrl"/"$SubSite2Url

#->SubSite3<-
$SubSiteTitle3 = "This is SubSite - 3 - Title"
$SubSite3Url = "SubSite3"
New-SPWeb –url $WebAppUrl"/"$SubSite3Url -name $SubSiteTitle3 -Template "STS#0" 
–AddToTopNav –UniquePermissions –UseParentTopNav
Write-Host 'Create new SubSite:' $SubSiteTitle3 '-> Url:'$WebAppUrl"/"$SubSite3Url

List of SharePoint 2013 Template Sites:

Template ID Title
GLOBAL#0 Global template
STS#0 Team Site
STS#1 Blank Site
STS#2 Document Workspace
MPS#0 Basic Meeting Workspace
MPS#1 Blank Meeting Workspace
MPS#2 Decision Meeting Workspace
MPS#3 Social Meeting Workspace
MPS#4 Multipage Meeting Workspace
CENTRALADMIN#0 Central Admin Site
WIKI#0 Wiki Site
BLOG#0 Blog
SGS#0 Group Work Site
TENANTADMIN#0 Tenant Admin Site
APP#0 App Template
APPCATALOG#0 App Catalog Site
ACCSRV#0 Access Services Site
ACCSRV#1 Assets Web Database
ACCSRV#3 Charitable Contributions Web Database
ACCSRV#4 Contacts Web Database
ACCSRV#5 Projects Web Database
ACCSRV#6 Issues Web Database
ACCSVC#0 Access Services Site Internal
ACCSVC#1 Access Services Site
BDR#0 Document Center
DEV#0 Developer Site
DOCMARKETPLACESITE#0 Academic Library
EDISC#0 eDiscovery Center
EDISC#1 eDiscovery Case
OFFILE#0 (obsolete) Records Center
OFFILE#1 Records Center
OSRV#0 Shared Services Administration Site
PPSMASite#0 PerformancePoint
BICenterSite#0 Business Intelligence Center
SPS#0 SharePoint Portal Server Site
SPSPERS#0 SharePoint Portal Server Personal Space
SPSPERS#2 Storage And Social SharePoint Portal Server Personal Space
SPSPERS#3 Storage Only SharePoint Portal Server Personal Space
SPSPERS#4 Social Only SharePoint Portal Server Personal Space
SPSPERS#5 Empty SharePoint Portal Server Personal Space
SPSMSITE#0 Personalization Site
SPSTOC#0 Contents area Template
SPSTOPIC#0 Topic area template
SPSNEWS#0 News Site
CMSPUBLISHING#0 Publishing Site
BLANKINTERNET#0 Publishing Site
BLANKINTERNET#1 Press Releases Site
BLANKINTERNET#2 Publishing Site with Workflow
SPSNHOME#0 News Site
SPSSITES#0 Site Directory
SPSCOMMU#0 Community area template
SPSREPORTCENTER#0 Report Center
SPSPORTAL#0 Collaboration Portal
SRCHCEN#0 Enterprise Search Center
PROFILES#0 Profiles
BLANKINTERNETCONTAINER#0 Publishing Portal
SPSMSITEHOST#0 My Site Host
ENTERWIKI#0 Enterprise Wiki
PROJECTSITE#0 Project Site
PRODUCTCATALOG#0 Product Catalog
COMMUNITY#0 Community Site
COMMUNITYPORTAL#0 Community Portal
SRCHCENTERLITE#0 Basic Search Center
SRCHCENTERLITE#1 Basic Search Center
SRCHCENTERFAST#0 FAST Search Center
visprus#0 Visio Process Repository

Template IDT

Custom menu in SharePoint using Taxonomy Term Store Navigation – Programmatically C#

This is a simple example how to access to Taxonomy Term Store properties in SharePoint using c# and create a Custom Menu.

First, create the terms on your Taxonomy Manage Navigation. – Site settings> Site Administration > Term Store Management

To get the Simple Link URL information using C#:

DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] { new DataColumn("Title"), 
                                       new DataColumn("Url") });
     ...
         foreach (var term in termSet.Terms)
         {
            if (term.IsDeprecated == false)
            {
               try
               {
                 var name = term.Name;
                 var url = term.LocalCustomProperties["_Sys_Nav_SimpleLinkUrl"];
                 dt.Rows.Add(new String[] { name, url });                 
               }
               catch (KeyNotFoundException) { }
             }
           }
       ...
         rptFooter.DataSource = dt; 
         rptFooter.DataBind();

Create ASPX repeater to construct your Menu

<asp:Repeater ID="rptFooter" runat="server">
 <ItemTemplate>
  <li>
  <asp:Button runat="Server" Text='<%# DataBinder.Eval (Container.DataItem, "Title") %>'
  PostBackUrl='<%# DataBinder.Eval (Container.DataItem, "Url") %>' />
 </li>
  </ItemTemplate>
</asp:Repeater>

The full list of Term Set properties on Manage Navigation in SharePoint 2013:

_Sys_Nav_Title: the Navigation Node Title

_Sys_Nav_FriendlyUrlSegment: the Friendly Url, also represented by the FriendlyUrlSegment property of the NavigationTerm class.

_Sys_Nav_TargetUrl: the target URL, also represented by the TargetUrl property of the NavigationTerm class.

_Sys_Nav_TargetUrlForChildTerms: the target URL for child terms, also represented by the TargetUrlForChildTerms property of the NavigationTerm class.

_Sys_Nav_CatalogTargetUrl: the catalog target URL, also represented by the CatalogTargetUrl property of the NavigationTerm class.

_Sys_Nav_CatalogTargetUrlForChildTerms: the catalog target URL for child terms, also represented by the CatalogTargetUrlForChildTerms property of the NavigationTerm class.

Change MasterPage of SharePoint Sites via PowerShell

On SharePoint Server, you can change MasterPage using Powershell Script.

First, you need check if your masterpage file that there you want apply is in a correctly library.

Go to Settings > Site Settings > Web Designer Galleries > Masterpage and Page Layout.

If you have the file on directory you just need run the script bellow.

      $web = Get-SPWeb siteurl
      $web.MasterUrl = “masterpagerelativeurl”
      $web.Update()
      $web.Dispose()

Examples:

foreach ($site in get-spsite -url http://fcsharepoint*) {
$web = Get-SPWeb $site
$web.CustomMasterUrl = “/_catalogs/masterpage/MasterPage.master”
$web.Update()
}
$web = Get-SPWeb http://fcsharepoint/sites/test
$web.MasterUrl = "/sites/test/_catalogs/masterpage/customMasterPage.master"
$web.Update()
$web.Dispose()

If something went wrong verify if Feature – SharePoint Server Publishing Infrastructure is Enable.