Showing posts with label MasterPage in SharePoint. Show all posts
Showing posts with label MasterPage in SharePoint. Show all posts

Tuesday, March 29, 2016

How to get current master page and change it on the Site using javascript

 GET request

/_api/Web?$select=CustomMasterUrl,MasterUrl

function MastePageChange() {
    var clientcontext;
    var cweb;
    var customMasterURL = '/_catalogs/masterpage/NewMasterPage.master';
    clientcontext = new SP.ClientContext.get_current();
    cweb = clientcontext.get_web();
    cweb.set_customMasterUrl(masterPageUrl);
    cweb.set_masterUrl(masterPageUrl);
    cweb.update();
    clientcontext.executeQueryAsync(function() {
        alert("Master Page has been changed successfully \n" + customMasterURL);
    }, function(sender, args) {
        alert("Error: " + args.get_message());
    });
}

MastePageChange();

Friday, January 29, 2016

How to Hide Ribbon from Anonymous users in SharePoint 2013

In 2013, we can’t modify the master page .master. We need to modify the .html file associated with the master page.

We have to modify .html
 <!--MS:--> and <!--ME:--> that shows the markup inside of the tags for the  masterpage


Search for text in html file “<div class =”ms-belltown-anonshow”>” tag

<!—MS:<SharePoint:SpSecurityTrimmedControl runat=”server” permission=”AddandCustomizepages”>—>

Add following code after closing div tag.

<!—MS:</SharePoint:SpSecurityTrimmedControl>—>




Sunday, January 10, 2016

how to hide master page style in list ,libraries and pages or popups ,IsDlg=0, IsDlg=1?


When user add URL  IsDlg=0, IsDlg=1
Add &IsDlg=1

hidden Ribbon bar 
Add &IsDlg=0

but there’s no scroll bars


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

<script type="text/javascript">

_spBodyOnLoadFunctionNames.push("hideItAll");

function hideItAll(){
    if(window.location.search.toLowerCase().indexOf("isdlg=1") > 0){
        $("#s4-ribbonrow").hide(); //ribbon bar

        //because the bar joins us late in the game, we need to throw CSS in to hide it
        $("head").append("<style>#Hero-WPQ2 { display:none }</style>");

        $("#CSRListViewControlDivWPQ2").hide(); //views and search bar
    }
}
</script>

Wednesday, December 9, 2015

To fix Add an App option in SharePoint 2013 "Apps you can add" is missing

Add the below lines in the MasterPage in SharePoint

<!--SPM:<SharePoint:AjaxDelta id="DeltaPlaceHolderLeftNavBar" BlockElement="true" runat="server">-->
<!--SPM:<asp:ContentPlaceHolder id="PlaceHolderLeftNavBar" runat="server">-->
<!--SPM:</asp:ContentPlaceHolder>-->
<!--SPM:</SharePoint:AjaxDelta>-->
<!--SPM:<SharePoint:AjaxDelta id="DeltaPlaceHolderPageTitleInTitleArea" runat="server">-->
<!--SPM:<asp:ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea" runat="server">-->
<!--SPM:</asp:ContentPlaceHolder>-->
<!--SPM:</SharePoint:AjaxDelta>-->

Friday, October 30, 2015

When click subsite logo to redirect to root site in Sharepoint site

In this post, site logo change to root site

1.Open you master page

For this generte site logo in Snippet Gallery

2.Find the text SharePoint:SPSimpleSiteLink
<!--MS:<SharePoint:SPSimpleSiteLink runat="server" CssClass="ms-siteicon-a" ID="x7917ecc8c38eab54c8c8d4bd69f58e33">-->
... 
<!--ME:</SharePoint:SPSimpleSiteLink>-->

3.Replace the text


<!--MS:<SharePoint:SPLinkButton runat="server" NavigateUrl="~sitecollection/" CssClass="ms-siteicon-a" ID="x7917ecc8c38d4bd69f5afkaf932523">-->
...

<!--ME:</SharePoint:SPLinkButton>-->


4.For site collection redirect option, Add the attribute NavigateUrl to this tag and set it value to "~sitecollection"
4.For site current site redirect option, Add the attribute NavigateUrl to this tag and set it value to "~site"

NavigateUrl="~sitecollection/"
NavigateUrl="~site/"