Archive for March, 2009

MOSS Branding - Site Actions

Monday, March 30th, 2009

There are some great browser add-ons out there to help you as you brand your SharePoint site. My favorite of these being Mozilla’s Firebug for FireFox. There are some fairly hard styles to catch though, even with the assistance of on of these add-ons. Ever try branding all those links in the Site Actions drop down for example?

Though not all of your users may use or even see the Site Actions menu, this is still an area of SharePoint branding that you should consider covering. Its important that you touch all the necessary areas of your site to give the users a completed and cohesive look/feel while using the site.

Generally, styles I primarily use to change the main elements of Site Actions are as follows, though a quick search for “ms-menuUI” in core.css will lead you to the quick realization that this list is not near exhaustive:

.ms-MenuUIPopupBody TABLE{
color: menu item text;
}
.ms-MenuUIItemTableCell,.ms-MenuUIItemTableCellCompact{
color: menu item text;
}
.ms-MenuUIItemTableCell A,.ms-MenuUIItemTableCellHover A,.ms-MenuUIItemTableCellCompact A,.ms-MenuUIItemTableCellCompactHover A{
color: menu item link;
}
.ms-menuitemdescription{
color: item description text;
}
.ms-MenuUIItemTableCellHover,.ms-MenuUIItemTableCellCompactHover{
color: item text on hover;
}
.ms-MenuUIItemTableHover{
background-color:#ffde67; row on hover
border: row on hover;
}
.ms-MenuUIItemTableHover .ms-menuitemdescription{
color: item description text on hover;
}
.ms-MenuUISeparator,.ms-MenuUISeparatorRtL,.ms-MenuUISeparatorLarge,.ms-MenuUISeparatorLargeRtl{
background-color: separator line;
}

MOSS Content Deployment

Wednesday, March 25th, 2009

SharePoint offers a lot of out-of-box features for managing content from an end user perspective.  Sometimes you may want your end users to have the capability to migrate content across multiple site collections, or even different web applications.  In my case, I needed a solution which would allow a user to publish a document, list, library, etc to a site external of the current site collection.  The solution for this was to build a custom feature utilizing Microsoft SharePoint Deployment.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.deployment.aspx

The deployment namespace allows you to package your content into a .cmp file and perform export/import operations, very similar to the concept behind doing so for a webpart through the UI.


//export
SPExportSettings mySettings = new SPExportSettings();
mySettings.SiteUrl = "http://mysharepointsite";
mySettings.ExportMethod = SPExportMethodType.ExportAll;
mySettings.FileLocation = "d:tempexportlocation";
mySettings.FileCompression = false;
mySettings.ExportObjects.Add(myExportObject);

SPExport export = new SPExport(mySettings);

myWeb.AllowUnsafeUpdates = true;
myWeb.Site.WebApplication.FormDigestSettings.Enabled = false;
myWeb.Update();
export.Run();
myWeb.AllowUnsafeUpdates = false;
myWeb.Site.WebApplication.FormDigestSettings.Enabled = true;
myWeb.Update();

//import
SPSite readerSite = new SPSite("http://sharepointreadersite");
SPWeb readerWeb = readerSite.OpenWeb();
SPWebApplication webApp = readerWeb.Site.WebApplication;

SPImportSettings settings = new SPImportSettings();
settings.SiteUrl = "http://sharepointreadersite";
settings.FileLocation = "d:tempexportlocation";
settings.FileCompression = false;
settings.RetainObjectIdentity = false;

SPImport import = new SPImport(settings);

webApp.FormDigestSettings.Enabled = false;
projectsWeb.AllowUnsafeUpdates = true;
projectsWeb.Update();

import.Run();

Something noteworthy here is that I exported the .cmp file to a location on the server.  In my case, the export and import web applications were both hosted on the same server.  You’ll want to be aware of this and make sure that wherever you place this .cmp file that both of your SharePoint sites have access to the location.  Also, I made a practice of deleting this file from the export location after an import attempt, without regard to whether the import was successful or not.

Your export object can range from a single file to an entire document library, though this will need to be defined in your export object properties for this export/import to function successfully.

Default CSS Settings

Wednesday, March 25th, 2009

Each browser applies its own default settings to HTML tags.  For example, while IE and Firefox may both add a default top margin to the <p> tag, the size of that margin spacing may be different in each browser.  Further, one browser may apply a default lower margin or padding, for example, while another browser may not.  Ignoring this issue, the spacing before or after <p> tags in your site may appear different between browsers.  This principle is true for many HTML tags, including:

  • All header tags <h>
  • <div> tags
  • <span> tags
  • <p> tags
  • All list tags <ul> <ol> <li>

While this list is not exhaustive, it does provide a starting place to tackle browser compatibility.  The example below illustrates the different default margins applied to the <p> in IE and Firefox.

A simple work around for this issue is to replace each browser’s default styles with your own designated style in the CSS:

p { padding: 0px 0px 0px 0px;  margin: 0px 0px 0px 0px; }

Inserting the above code into your CSS file will overwrite any default margins or padding added by each browser, giving your code a consistent style across all browsers.