Book Image

SharePoint 2013 WCM Advanced Cookbook

By : JOHN CHAPMAN
Book Image

SharePoint 2013 WCM Advanced Cookbook

By: JOHN CHAPMAN

Overview of this book

Table of Contents (19 chapters)
SharePoint 2013 WCM Advanced Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a timer job to ensure the site branding feature is activated


SharePoint provides a framework for tasks that can be executed at scheduled intervals called SharePoint timer jobs. These timer jobs, when configured, are executed by the SharePoint Timer Windows service. In a large site with a lot of contributors, there may be the need to enforce some rules in the environment in a more automated fashion, such as using consistent branding. In this recipe, we will create a timer job that ensures the site branding feature is activated on all sites in the site collection.

How to do it...

Follow these steps to create a timer job:

  1. From the Solution Explorer pane, right-click on the project name.

  2. Select Add and then select Class.

  3. Provide a name for the class (for instance, BrandingTimerJob).

  4. Give the class a public access modifier and inherit from the SPJobDefinition base class as follows:

    public class BrandingTimerJob : SPJobDefinition
  5. In the BrandingTimerJob class, add a static GUID for our SiteBranding...