Creating a master page with editing controls only available to editors

In this recipe, we will create a custom master page that is branded for a public-facing SharePoint site. In addition, this master page will only show the page editing controls to those with contribute access to the SharePoint site.

To see the results of this recipe, you will need to be able to access the SharePoint site both anonymously and logged in.

How to do it...

Follow these steps to create a master page with editing controls only available to editors:

  1. Open SharePoint Designer.
  2. Select Open Site. Enter the complete URL to the SharePoint site and select Open.
  3. Add a PublicMasterPage.css stylesheet file to the resources folder located at_catalogs/masterpage/resources.
  4. From the Navigation pane, select Master Pages.
  5. In the list of files in the Master Pages library, make a copy of seattle.master (for our example, we have renamed it Seattle_PublicWebsite.master).
  6. Check out the new Seattle_PublicWebsite.master master page.
  7. Open the Seattle_PublicWebsite.master master page.
  8. Add a reference to our PublicMasterPage.css stylesheet file.
    <SharePoint:CssRegistration ID="customCssRegistration" Name="<% $SPUrl:~Site/_catalogs/masterpage/resources/PublicMasterPage.css %>" runat="server"></SharePoint:CssRegistration> 
  9. In our stylesheet file, add the following content padding to the workspace and a background color for the body:
    #s4-workspace {
    background: #FFFFFF;
    margin: 50px 100px 50px 100px;
    }
    body {
    background: #999999;
    }
    #s4-ribbonrow, #suiteBar {
    background: #FFFFFF;
    }
  10. In our custom master page, locate the element with the suiteBar ID as follows:
  11. Before the suiteBar element, add the beginning tag for a <SharePoint:SPSecurityTrimmedControl> control with the permissions set to EditListItems as shown in the following line of code:
    <SharePoint:SPSecurityTrimmedControl ID="customSecurityTrimmedControl" PermissionContext="CurrentSite" PermissionsString="EditListItems" runat="server">

    Tip

    The EditListItems permission level will require the user to have contribute access to the site in order to see the items in the control.

  12. In our custom master page, locate the element with the s4-workspace ID.
  13. Before the s4-workspace element, add the following end tag for the <SharePoint:SPSecurityTrimmedControl> control:
    </SharePoint:SPSecurityTrimmedControl>
  14. Save the master page.
  15. Check in and publish the master page using the Check In and Publish options.
  16. Set the master page as the Site Master Page.
  17. Navigate to the site in your preferred web browser anonymously and log in to observe the results.
    How to do it...

How it works...

In this recipe, we used CSS to provide padding around the content of the page and used an SPSecurityTrimmedControl control to hide the page editing controls to users who do not have access to edit the pages.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.179.59