Archive for Master Page

SharePoint 2013: Create Master Page using Visual Studio 2012

Scenario:

You can find many blogs on how to create SharePoint 2013 master page in Visual Studio 201. We faced following issue while creating master page. Long story, we need to create master pages for our new SharePoint 2013 environment. As with our previous experience, we decided to create them in Visual Studio. Everything works fine but when we try to deploy wsp via Visual Studio 2012, master pages are not uploaded in “Master pages and Layout Library”. The problem was in the XML that was written in “Elements.xml” file.

Resolution:

Before moving to XML that worked, we would like to share all the XML that didn’t worked. We are not sure why they didn’t work. Perhaps, anything wrong on our side.

XML that didn’t work:

<Elements
xmlns=http://schemas.microsoft.com/sharepoint/>

<Module Name=MasterPages” RootWebOnly=TRUE >

<File Path=MasterPages\ABCIntranet.master” 

Url=_catalogs/masterpage/ABCIntranet.master” 

IgnoreIfAlreadyExists=true >

<Property Name=UIVersion” Value=15></Property>

</File>

</Module>

</Elements>


<Elements xmlns=http://schemas.microsoft.com/sharepoint/>

<Module Name=MaterPage” Url =_catalogs/masterpage” List=116>

<File Path=MaterPage\ABCIntranetMasterPage.master” 

Url=ABCIntranetMasterPage.master
Type=GhostableInLibrary” IgnoreIfAlreadyExists=FALSE />

</Module>

</Elements>


<Elements xmlns=http://schemas.microsoft.com/sharepoint/>

<Module Url=_catalogs/masterpage” Name=MasterPage>

<File Url=ABCIntranetMasterPage.master” Type=GhostableInLibrary
IgnoreIfAlreadyExists=TRUE” 

Path=MasterPage\ABCIntranetMasterPage.master/>

</Module>

</Elements>

XML that did work is:

<Elements xmlns=http://schemas.microsoft.com/sharepoint/>

<Module Name=MasterPage” List=116” Url=_catalogs/masterpage
Path=MasterPage” RootWebOnly=TRUE>

<File Url=ABCIntranet.master” Type=GhostableInLibrary >

<Property Name=UIVersion” Value=15 />

</File>

</Module>

</Elements>

Advertisements

Leave a Comment

SharePoint: Remove Page node from breadcrumb

Scenario:

We were using breadcrumb and wanted to remove “Pages” library link from breadcrumb.

Resolution:

The control we were using was:

<asp:SiteMapPath
SiteMapProvider=”SPContentMapProvider” id=”ContentMap” SkipLinkText=”” RenderCurrentNodeAsLink=”false”
NodeStyle-CssClass=”ms-sitemapdirectional” runat=”server”/>

One way of removing the “Pages” node is to use “CurrentNavSiteMapProviderNoEncode” instead of “SPContentMapProvider”. Also, make sure that you have checked “Show Pages” under “Site Settings -> Navigation ->Current Navigation”.

This approach has one drawback that if you are using OOTB Left Navigation, then, pages will also start appearing in the “Left Navigation”. In order to avoid this, we are left with jQuery. Below is the snippet to accomplish above.

First include jQuery in your page:

<script
src=”http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js”></script>

Add you control as:

<asp:SiteMapPath
SiteMapProvider=”SPContentMapProvider” id=”ContentMap” SkipLinkText=”” RenderCurrentNodeAsLink=”false” 
NodeStyle-CssClass=”ms-sitemapdirectional” runat=”server”/>

Add following after the control

<script
type=”text/javascript”>

$(“Span[id=’ctl00_ContentMap’]”).children().each(function(){

if($(this).text()==’Pages’)

{

$(this).next().remove();

$(this).remove();

}

</script>

Leave a Comment