Posts tonen met het label branding. Alle posts tonen
Posts tonen met het label branding. Alle posts tonen

dinsdag 29 januari 2008

generic feature to install a custom masterpage

During my current job i needed to create a few new visual designs and install them as a masterpage. I searched the internet and found a custom masterpage changer, and used it. But it didnt fullfill my needs. WHen using this solution, i needed to have 7 assemblies for 7 masterpages. I changed the code and the feature.xml a bit to make it more generic. The code isn't too neat, it's more of quickly hacked ;)

How to use it?

Create a new dir with the name of your feature. Put an elements.xml, feature.xml and a dir with the name of your masterpage([name]). put the NewDesign.master, and custom css files (and maybe some other files) into that directory.

FeatureName
|- [Name]
|- Feature.xml
|- Elements.xml

put the ChangeMaster assembly into the GAC.


feature.xml:

<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
Id="90969656-A1C9-4f40-A95F-A3BDDF5723BF"
Title="Use Custom Master File"
Scope="Web"
ReceiverAssembly="CustomMaster, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=b2f164534d725b81"
ReceiverClass ="CustomMaster.ChangeMaster"
>
<ElementManifests>
<ElementManifest Location="Elements.xml"/>
</ElementManifests>
<Properties>
<Property Key="VisualDesignName" Value="[Name]" />
</Properties>
</Feature>



elements.xml:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="AddMasters" Url="_catalogs/MasterPage" >
<File Url="[NAME]/NewDesign.master" Type="GhostableInLibrary"
IgnoreIfAlreadyExists="True"/>
<File Url="[NAME]/custom.master" Type="GhostableInLibrary"
IgnoreIfAlreadyExists="True"/>
<File Url="[NAME]/custom.css" Type="GhostableInLibrary"
IgnoreIfAlreadyExists="True"/>
<File Url="[NAME]/custom_tables.css" Type="GhostableInLibrary"
IgnoreIfAlreadyExists="True"/>
</Module>
</Elements>


using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;

namespace CustomMaster
{
public class ChangeMaster : Microsoft.SharePoint.SPFeatureReceiver
{
public override void FeatureInstalled
(SPFeatureReceiverProperties properties)
{
}
public override void FeatureUninstalling
(SPFeatureReceiverProperties properties)
{

}
public override void FeatureActivated
(SPFeatureReceiverProperties properties)
{
string strKey = "VisualDesignName";
string name = properties.Definition.Properties[strKey].Value;

SPWeb CurrentWeb = properties.Feature.Parent as SPWeb;
string filler = "/";
if (CurrentWeb.ServerRelativeUrl == "/")
{
filler = "";
}
CurrentWeb.MasterUrl = CurrentWeb.ServerRelativeUrl + filler + "_catalogs/masterpage/" + name + "/NewDesign.master";
CurrentWeb.CustomMasterUrl = CurrentWeb.ServerRelativeUrl + filler + "_catalogs/masterpage/" +name + "/custom.master";
CurrentWeb.Update();
}
public override void FeatureDeactivating
(SPFeatureReceiverProperties properties)
{
SPWeb CurrentWeb = properties.Feature.Parent as SPWeb;

string filler = "/";
if (CurrentWeb.ServerRelativeUrl == "/")
{
filler = "";
}

CurrentWeb.MasterUrl = CurrentWeb.ServerRelativeUrl + filler + "_catalogs/masterpage/default.master";
CurrentWeb.CustomMasterUrl = CurrentWeb.ServerRelativeUrl + filler + "_catalogs/masterpage/default.master";
CurrentWeb.Update();
}
}
}

maandag 17 december 2007

CSS styleguide for sharepoint 2007

When creating a new masterpage and/or a theme for sharepoint 2007, there are really a lot of default styles used. Heather Solomon wrote a CSS styleguide with a lot of commonly used styles when branding sharepoint

Click here for the reference guide

Branding Sharepoint

it can be a pain when you want to brand a sharepoint for the very first time. That's why i decided to make up this post. If you want some more information, you can always send me an email about branding.


* download the minimalistic masterpage click here.
* create a html mockup (I prefer tables!)
* copy the masterpage to _catalogs/masterpage of your page (within sharepoint designer)
* paste the html mockup in the minimalistic masterpage
* make sure to place the masterpage contentholders between two div-tags: in this way, the content will be displayed below your html mockup.
* cut and paste contentplaceholders one by one to the place where you want your content to be shown. If you dont need a certain content placeholder, DONT delete it, but place it inside the asp:panel tags. In this way, they are available, but they won't be shown.
* Add a css with your custom style's in it.
* you are finished

If you want to, you can deploy this masterpage with a (webapplication) feature, it will be available troughout whole the site then.

donderdag 15 november 2007

Theming in Sharepoint 2007

Creating Themes in MOSS 2007

  • On the Sharepointserver open the Themes folder. Default it is located c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\Themes


  • Make a copy one of the existing theme folders and its contents rename it e.g. MyTheme.

  • Rename the .INF file within the MyTheme folder to MyTheme.INF

  • Edit MyTheme.INF. At the info section, Change the title, to MyTheme. In the titles section, rename the names to your new name. this section is to present the name in the different language.

  • Provide an image to give a preview of your theme. This image should be placed in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES. E.g. tmbMyTheme.gif

  • Modify the c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\Layouts\1033\SPTHEMES.xml to include a reference to the new MyTheme theme.

  • Modify the css to your needs

  • reset iis

  • apply the theme to a test site

  •