Category Archives: Navigation

Hide Ribbon and SuitBar of SharePoint 2013 for a specifique Zone – Using JavaScript and C#

One way to hide Ribbon and SuitBar of SharePoint 2013 for a specific zone, like Internet for example – you can use Javascript + Css and run it in a UserControl.

1 – Create a simple UserControl on your solution and add it on your MasterPage.

In ASCX file of your UserControl add the following code:

<script type="text/javascript">
    function hideRibbon(){
        document.getElementById("s4-ribbonrow").style.display = "none !important";
        document.getElementById("suiteBar").style.display = "none !important";
    }
</script>

On code behind of UserControl,  you go execute the javascript function, using the following code:

Example to hide in Internet zone

using Microsoft.SharePoint.Administration;
...

protected void Page_Load(object sender, EventArgs e)
{
 if (SPContext.Current.Site.Zone == SPUrlZone.Internet)
 {
 Page.ClientScript.RegisterStartupScript(this.GetType(),"","hideRibbon();",true);
 }
}
Advertisements

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.