Build your own custom administration

Managing application specific configuration is mostly done within an application page (aka layouts page). Navigating to these pages is done via custom actions, which adds links to for example the Site Settings page. The challenge starts when the number of application pages grows. Do you keep adding them to the Site Settings page? Do you show them on all Site Settings pages in the web application of every web?

What you need is a centralized administration, like the Central Administration, controlling your application configuration. The Central Administration in SharePoint has two sorts of pages. The homepage (default.aspx) providing an overview and pages like Application Management showing a collection of links related to Application Management.

CentralAdministration_Homepage CentralAdministration_ApplicationManagement

It’s easy to build your own custom administration site. The image below shows my own administration site. Do you see the resemblance?

ApplicationAdministration_Homepage ApplicationAdministration_Security

Creating these pages is pretty straightforward when using the FeatureLinkSections class together with “LinkSectionLevel1.ascx” and “LinkSectionLevel2.ascx” controls. This web control handles the rendering of the links based on enabled features in the current context. The links are provisioned by custom actions as part of a (enabled) feature.

<SharePoint:FeatureLinkSections Runat="server" Id="SettingLinksV4" CellPadding="4" CellSpacing="4" Location="Contoso.SharePoint.AdminPage" LinkSectionControl="LinkSectionLevel1.ascx" />

The Location attribute is an unique identifier indicating the location where links are provisioned. The location is used in the custom action XML (shown below) to point to the location in the FeatureLinkSections control.

<!-- Admin Page - Security --> <CustomActionGroup Id="ContosoSecurity" Title="Contoso Security" Location="Contoso.SharePoint.AdminPage" Sequence="10" Description="" ImageUrl="/_layouts/images/ SiteSettings_UsersAndPermissions_48x48.png" /> <CustomAction Id="ContosoAdmins" GroupId="ContosoSecurity" Location="Contoso.SharePoint.AdminPage" Rights="EnumeratePermissions,BrowseUserInfo" Sequence="10" Title="Contoso Administrators" Description="..."> <UrlAction Url="_layouts/people.aspx" /> </CustomAction>

The FeatureLinkSections control uses two views controlled by the LinkSectionControl attribute.

LinkSectionLinks1.ascx

Shows a 48×48 icon for the group and links are placed below each other.

LinkSectionLinks1

LinkSectionLinks2.ascx

Shows a 32×32 icon for the group and links are delimited by the “|” character. LinkSectionLinks2

 

Visual Studio solution

I included the Visual Studio project containing the following components:

  • AdminPages_Web feature: Web scoped feature with event receiver updating the welcome page and quicklaunch. The feature contains the following components:
    • AdminPage module
    • AdminPageActions custom actions
    • PBWebTemplate element
    • Event receiver
  • AdminSite_Site feature: Site collection scoped feature containing the web template for creating the web. The feature contains the following components:
    • AdminWebTemplate web template
  • AdminPageActions custom actions: All custom actions containing all links displayed in the central adminstration.
  • AdminPages module: Provisions the adminpage.aspx and security.aspx pages in the web root folder.
  • AdminWebTemplate web template: Contains the web template for creating the web.
  • PBWebTemplate element: Property bag element with unique web template id

DownloadYou can download the WSP package and source code at http://sp2010admin.codeplex.com/.

Create site-collection based on custom sandbox solution template

SharePoint provides a couple out-of-the-box web templates. When implementing SharePoint this you probably want to provide a customized template which suit the needs. A big advantage would be if you are not depending on an administrator and being able to provide your own custom template. With sandboxed solution in SharePoint 2010 this is possible! What is really nice about this, you can also do this when creating a site-collection and choose the custom template for the root web.

I created a site-collection based on the out-of-the-box Team Site template (STS#1). Made changes to the site by adding a new list FAQs, added a task to the Task list and added the Tasks list on the homepage. This is the basics for my template.

Template - Team Site

Next step is to save the team site as a template.

  1. Click Site Actions » Site Settings
  2. Click Save site as template
  3. Fill in the fields
    • File name: TeamSiteTemplate
    • Template name: Team Site Template
    • Check the Include Content checkbox
  4. Click OK
  5. Click the link Solution Gallery in the “Operation Completed Successfully” window
  6. Click the “TeamSiteTemplate” name to download the WSP solution file, save on your desktop

At this point we have a WSP solution file containing a template for a new site. We want to create a new site-collection based on this template. But we do not want to upload the WSP solution as a Farm Solution. We can create the new site-collection based a sandbox solution containing the template.

  1. Open SharePoint 2010 Central Administration via Start Menu
  2. Click Application Management » Create Site Collections
  3. Select a web application
  4. Fill in the fields
  5. When selecting a template, click the Custom tab and select “< Select template later… >”
  6. Click OK

The site-collection is created but has no template. Meaning it is also not provisioned with lists and libraries. We want the site-collection to be based on our sandboxed solution template. Next steps will explain!

  1. Open the new site-collection URL
  2. The “Template Selection” page is shown
    Template - Template Selection
  3. Click Solution Gallery
  4. Upload the sandboxed solution by click the Solutions tab in the ribbon
  5. When uploaded, activate the solution by clicking Activate in the Solution Gallery – Activate Solution window
  6. Go back to the Template Selection page (_layouts/templatepick.aspx) by using the Back-button
  7. Refresh the page, the Custom tab should show up
    Template - Template Selection 2
  8. Select the Custom tab and select our “TeamSiteTemplate”
  9. Click OK

Now the site-collection is provisioned based on the sandboxed solution. The site is provisioned with the FAQs list and one task in the Task list which is shown on the homepage.

Template - Complete