Blog Archives
Hide Ribbon and SuitBar of SharePoint 2013 for a specifique Zone – Using JavaScript and C#
Posted by Fábio Carvalho
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); } }
Posted in Navigation, Ribbon, SuitBar
Tags: ASP.NET, C#, CSS, JavaScript, Master Page, Navigation, Source Code C#
Custom menu in SharePoint using Taxonomy Term Store Navigation – Programmatically C#
Posted by Fábio Carvalho
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.
Posted in c#, Navigation
Tags: ASP.NET, Branding, C#, Master Page, Navigation, Server Side, Tagging, Taxonomy