Monday, February 13, 2012

Summary View Bug: SharePoint 2010 Publishing

Have you ever struggled with the summary view for Links, Announcements, Events, Documents, Discussions or any other major type of SharePoint 2010 list or library on publishing pages? Well if so I hope this post will help with the identification/resolution of this bug. Hopefully Microsoft will supply a fix for this someday...

Here is a common scenario:

  1. You create a SharePoint Publishing Site or you create a blank site and then enable the publishing feature.
  2. From that publishing site you create a simple links list. You add in a few links and want to then display it on your publishing page.
  3. You edit the publishing page and then click on a webpart zone and add the newly created links list on the page.
  4. From here instead of configuring the webpart to display in summary view you simply keep the current view and check the page in.
  5. You then edit/check out the page again and decide to modify the links list to show in “Summary View” to get it to display like a bulleted list of links.
  6. You edit the page and then modify the shared links list webpart. In the tool pane you change the view to “Summary View”.

image

  1. You click on Apply or Ok and it seems to look correct, however as soon as you check the page in or publish the page the view that you set on the webpart is back to the default.
  2. At this point you are frustrated and have no idea what when wrong. You spend about 2 hours banging your head against the wall… Finally you resort to removing the webpart, add it back in, change the view to summary and then publish the page hoping that it will be fixed.
  3. And then to your surprise it worked and your link lists displays as normal… Now you are completely confused and just happy that it is working…
  4. Sound familiar?

The key part of this bug is that the webpart was not set to summary view before it was checked in/published. If the page was just saved and not checked in there would not be an issue. It has something to do with the versioning of pages and the publishing feature with pages. This is not an issue with sites that do not have publishing pages where you simply save and close the page (Blank/team sites).

To quickly fix a webpart that will not go into summary view you will have to remove the webpart from the page and then add it back in. Once it is back on the page change it to summary view, it will then take the updates. This happens for all lists and library summary views. It is very confusing as a user that is building a page in stages that if they save the page and check it in for later editing the views are cached or saved in that state and cannot be changed.

The summary views are actually really helpful as they transform a basic looking list view into something that is more graphical and usable.

Links (Default View):
image

Links (Summary View):
image


Announcements (Default View):
image

Announcements (Summary View):
image

Hopefully this will be addressed in some future hotfix so that we do not have to remove our webparts from publishing pages to get them to display differently.

Write a comment if you found this to be useful or found yourself in this same situation.

Tuesday, January 31, 2012

Hide SP 2010 Page Layout Metadata - WebControls

In this post I will walk you through the process of adding in “Hidden” metadata to your page layouts so that they are only visible when editing the page. For example if you want to create a news article with categories, start date, end date, keywords, and other metadata that might not be relevant to the consumer then instead of forcing your content authors to create content in the edit mode and then force them to update metadata by editing the page properties why not have them all on the page. This allows for a single page authoring experience.

This post also provides the specific field names for the most common SharePoint 2010 base columns and web controls. (Really good stuff)

Microsoft.SharePoint.WebControls Namespace
Standard columns that are used for most metadata column types.
URL: http://msdn.microsoft.com/en-us/library/ms413880.aspx
Example:
<SharePointWebControls:RichTextField FieldName="MultipleLines" runat="server" />

image

Microsoft.SharePoint.Publishing.WebControls Namespace
Enhanced publishing controls that are used for rich media, rich content, and links.
URL: http://msdn.microsoft.com/en-us/library/ms551164.aspx
Example:
<PublishingWebControls:SummaryLinkFieldControl FieldName="SummaryLinks" runat="server" />

image

Microsoft.SharePoint.Portal.WebControls Namespace
These controls will need a reference added to the top of your page layouts and can include the ratings and note board functionality.
URL: http://msdn.microsoft.com/en-us/library/ms519088.aspx
Example:
<SharePointPortalControls:AverageRatingFieldControl FieldName="AverageRating" runat="server" />

image

Step 1: Creating the hidden container for your metadata
In this first task you will be creating a hidden container for the metadata that will be applied to your publishing page.

  • Create a new page layout and open it up in SharePoint Designer.
  • Add in the following control within a <TD> near the bottom of your page:

<PublishingWebControls:editmodepanel runat="server" id="editmodepanel1"></PublishingWebControls:editmodepanel>

  • Basically anything that gets added within this control will only display in edit mode.
  • Then to add some visual style to this control so that your authors feel comfortable that this content is not visible add in the following HTML within the control above:

<table cellpadding="0" cellspacing="0" width="100%" class="company-hiddeninfo">
<tr>
<td class="company-hiddeninfo-label">Hidden SharePointWebControls:
</td>
</tr>
</table>

  • Then Add in the following CSS your custom style sheet or at the top of your page layout within the AdditionalPageHead placeholder.

<style type="text/css">               
/***** Content Area - Hidden Metadata Panel Style *****/
.company-hiddeninfo{
    background-image: url(/_layouts/images/contentFooter.png);
    background-position: top left;
    background-repeat: repeat-x;
    border: 2px #4e648a dashed;
    border-top: 8px #4e648a solid;
    background-color: #EEE;
    padding: 10px;
    margin-bottom: 20px;
    width: 600px;
    margin: auto;
}
.company-hiddeninfo-label{
    font-family: Arial, sans-serif !important;
    font-size: 20px;
    color: #4e648a;
    font-weight: bold;
    padding: 5px 0px 10px 8px;
    text-align: left !important;
}
.company-hiddeninfo-notrequired,
.company-hiddeninfo-required{
    padding: 3px 0px 3px 0px;
}
.company-hiddeninfo-notrequired .ms-formfieldcontainer{
    border-left: 3px transparent solid;
}
.company-hiddeninfo-required .ms-formfieldcontainer{
    border-left: 3px #F00 solid;
}
.company-hiddeninfo .ms-formfieldvaluecontainer{
    background-color: #FFF;
}
</style>

  • The page should look similar to the following:

image

Step 2: Creating Additional columns within pages library
In this step you will be adding in some basic columns to the pages library. You could get more fancy by creating your own custom content type and make your custom site columns available within the whole site collection. However in this example to keep it simple we are simply just adding in regular columns to a single pages library.

  • Navigate to the pages library where you are going to be storing your pages.
    • (Requires site collection Publishing infrastructure and site publishing feature to be turned on within the site.)
  • Within the ribbon click on the “Library” tab and then click on “Create Column”
  • A dialog window will appear. Simple type in a column name (I would suggest not using spaces) Example: “StartDate”
  • Then Choose the appropriate column type.
  • Do this for as many columns as you need.

Step 3: Adding Newly Created Columns to Page Layout
In this step we will be editing the page layout to add those custom columns to the hidden section within your custom page layout.

  • Open up the page layout in SharePoint Designer 2010.
  • For non-required fields type in the following:

<tr>
<td class="company-hiddeninfo-notrequired">
</td>
</tr>

  • For required fields type in the following:
<tr>
<td class="company-hiddeninfo-required">
</td>
</tr>
  • Then to add in your custom fields this is where it will get a little tricky.
  • For all common SharePoint.WebControls they will be using the following format:
  • Red is the Class name Example: TextField
  • Blue is the Field Name Example: SingleLine

<SharePointWebControls:Class FieldName="Name" runat="server" />

  • To find the Field Name simply navigate to the library settings of your pages library.
  • Within the section called “Columns” right click on the column title that you want and choose “Properties”
  • Within the Adderess URL find the part where it shows “Field=” right after that will be your field name.
  • Each field type needs to have the correct class or the page will error out.
  • Below is a table that you can use to figure out what class to be used with each field/column type.
Field/Column Type <SharePointWebControls:

Single Line Of Text

TextField

Multiple Lines Of Text

RichTextField

Choice - Drop-Down Menu

DropDownChoiceField

Choice - Radio Buttons

RadioButtonChoiceField

Choice - Checkboxes

CheckBoxChoiceField

Number

NumberField

Currency

CurrencyField

Date and Time -

datetimefield

Lookup

LookupField

Yes/No

BooleanField

Person or Group

UserField

Hyperlink or Picture

UrlField

Calculated CalculatedField
  • So now that you have the field name and the class type you can then add them within the required or not required TD’s within the hidden page layout element.
  • In the example code below there are two custom columns being displayed. The first is the single line of text column that is not required. The second is the multiple lines of text column that is required. Notice the red visual indicator shown on the left added by the custom CSS.

<tr>
<td class="company-hiddeninfo-notrequired">
<SharePointWebControls:TextField FieldName="SingleLine" runat="server" />
</td>
</tr>
<tr>
<td class="company-hiddeninfo-required">
<SharePointWebControls:RichTextField FieldName="MultipleLines" runat="server" />
</td>
</tr>

image

Step 4: Adding your own labels and description text
Some web forms are confusing and we want our content authors to provide the best data possible. This is why we need to clearly label and guide our users on what type of information to provide and in what format. To do this we can easily add in our own labels to the control tabs and also provide instructional text for each control. 
  • If you want to change the labels on the form elements you can simply add in the InputFieldLabel="" Which will the allow you to change the title to what ever you want. See Red Text below:
  • You can also add in descriptive text below the control so that you can provide instructional text for your content authors. See blue text below

<tr>
<td class="company-hiddeninfo-notrequired">
<SharePointWebControls:TextField FieldName="SingleLine" InputFieldLabel="Single Line Of text" runat="server" />
<div style="padding: 0px 0px 10px 10px;">
This short description will be limited to <b>255</b> characters
</div>
</td>
</tr>

image

Step 5: Adding in Publishing Web Controls
Some of the basic publishing web controls for Welcome and Article page layout content types includes the Page Content, Page Image, and a Summary Links. Since these columns are already created you can easily just add them to your page by doing the following:

  • For all common SharePoint.WebControls they will be using the following format:
    • Note that the start of the control begins with “Publishing” and not “SharePoint”.
  • Red is the Class name Example: TextField
  • Blue is the Field Name Example: SingleLine

<PublishingWebControls:Class FieldName="Name" runat="server" />

  • As with the others each field type needs to have the correct class or the page will error out.
  • Below is a table that you can use to figure out what class to be used with each publishing field/column type.
FieldName=”” <PublishingWebControls:

PublishingPageContent

RichHtmlField

PublishingPageImage

RichImageField

PublishingRollupImage

RichImageField

SummaryLinks

SummaryLinkFieldControl

  • So now you can add in the following to display the page image and summary links.
    • Note: For some reason I was not able to place the publishing page content control into the hidden area.

<tr>
<td class="company-hiddeninfo-label">Hidden PublishingWebControls:
</td>
</tr>
<tr>
<td class="company-hiddeninfo-notrequired">
<PublishingWebControls:RichImageField FieldName="PublishingPageImage" runat="server" />
</td>
</tr>
<tr>
<td class="company-hiddeninfo-notrequired">
<PublishingWebControls:SummaryLinkFieldControl FieldName="SummaryLinks" runat="server" />
</td>
</tr>

image

Step 6: Adding Ratings and Note Board to your Page Layout 
One quick way to add some social fun to your pages is to include the ratings and note board feature to your custom page layout.

  • Fist you will need to turn on the ratings feature within the pages library. Navigate to the pages library settings and click on “Ratings Settings”. Then choose “Yes” to allow items in this list to be rated.
  • Next add in the following control registration at the top of your custom page layout to allow for SharePoint Portal Controls.

<%@ Register Tagprefix="SharePointPortalControls" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

  • Then within SharePoint Designer instead of adding the controls into the hidden area add them right above it.

<tr>
<td>
<SharePointPortalControls:AverageRatingFieldControl FieldName="AverageRating" runat="server" />
</td>
</tr>
<tr>
<td>
<SharePointPortalControls:SocialCommentWebPart runat="server" />
</td>
</tr>

image

Step 7: Download a sample layout to get started!
I have created a sample page layout that includes all of the base controls. Make sure that you remove the SharePoint Web Controls that are in the hidden element or your page will error out.
Download it here: HiddenProperties.zip

Screenshot in Display Mode:
image

Screenshot in Edit Mode:
image

Thanks! Add a comment if you found this helpful!
Erik Swenson

Friday, January 13, 2012

SharePoint 2010 Chrome Type CSS Classes

For content authors the ability to stylize web parts with just a few simple clicks is a big win. In some cases you might want to emphasize a web part on the page and make it stand out. There are basically 4 main web part styles/chrome that you can apply to any webpart.

You will notice below that the chrome type “None” and “Title Only” do not have a unique class name so they will share the same style. The “None” style simply does not show the web part title.

Chrome (None):
.ms-WPBody{
font-size:8pt;
font-family:verdana,arial,helvetica,sans-serif;
}
image

Chrome (Title Only):
.ms-WPBody{
font-size:8pt;
font-family:verdana,arial,helvetica,sans-serif;
}
image

Chrome (Title and Border):
.ms-WPBorder, .ms-WPBorderBorderOnly{
border-color:#9ac6ff;
border-width:1px;
border-style:solid;
}
image

Chrome (Border Only):
.ms-WPBorder, .ms-WPBorderBorderOnly{
border-color:#9ac6ff;
border-width:1px;
border-style:solid;
}
image

Since Title and Border and Border Only have their own unique classes you can apply custom styles properties and make them unique.

The next step is to learn how to apply these types of chrome types. First simply edit the page, click on the web part title arrow, and choose “Edit Web Part”.

image

Second, a panel will appear on the right side, click on the plus icon next to “Appearance”. From here you will be able to change the web part title and the chrome type.

image

Once you have chosen the Chrome Type simply click on the “OK” button and then save'/publish the page.

This is where the real fun begins. Now that you know how to apply the Chrome Type and you also have the class name for each one, you can easily create some really interesting styles for you web parts.

Example 1: (Title only/None with changes to the font)
.ms-WPBody{
font-size:14px;
font-family: Arial, sans-serif;
line-height: 20px;
letter-spacing: -.2px;
}

image


Example 2: (Title and Border with additional padding for text also includes custom border style and update web part title) 
.ms-WPTitle{
font-weight:bold;
font-family: Arial, sans-serif;
font-size:16px;
color: #C00;
}
.ms-WPBorder{
border: 3px #C00 dashed;
background-color: #EEE;
}
.ms-WPBorder .ms-WPBody{
padding: 10px;
font-size:12px;
color: #000;
line-height: normal;
letter-spacing: 0px;
}
image


Example 3: (Border only with custom border color and background image)
.ms-WPBorderBorderOnly{
border: 2px #7ea0dd solid;
background-image:url("/_layouts/images/MYSITEBG.GIF");
background-position:top left;
background-repeat:repeat-x;
}
.ms-WPBorderBorderOnly .ms-WPBody{
padding: 10px;
font-size:14px;
font-weight:bold;
color: #000;
line-height: normal;
letter-spacing: 0px;
}
image

Friday, December 23, 2011

My SP 2010 Branding Book is Finally Published!

After 6 months of hard work my SharePoint 2010 Branding Book: Practical SharePoint 2010 Branding and Customization 
is finally available for order from Amazon!!! If you are quick and order now, you can get it under your tree by tomorrow!

This book is a great deal as it comes with 2 pre-built visual designs, a visual studio solution for applying the designs, and of course a great resource book to help you on your branding journey.

The two Visual designs included in the SharePoint Branding Kit:

SharePoint Branding Kit Design 1

SharePoint Branding Kit Design 2

Many thanks to Chris Arella, Matt Lally, Robert Dornbush, and the team at Apress. This would not be at all possible without the support from my family and friends!

Happy Holidays!

Monday, November 14, 2011

SharePoint 2010 Branding Support File Statistics

Have you ever wondered what are the major font types, sizes, colors, and images for SharePoint 2010? This post will cover some of the major statistics that are related to SharePoint Branding.

This post originally spawned the topic of why SharePoint uses PT’s for font sizes when PX or EM’s are much better. Kyle Schaeffer created a very nice post about why you should use one format over the other: http://kyleschaeffer.com/best-practices/css-font-size-em-vs-px-vs-pt-vs/.

Over 75% of all font sizes declared in the standard SharePoint 2010 base style sheets use a font-size in Points.
Example: font-size:8pt;

Below are some other interesting statistics when it comes to other SharePoint 2010 support file statistics.

Server Side Files: Not surprisingly there are a lot of images that are used to make SharePoint look the way that it does. The number would be slightly larger if the sprite images were broken out. There a ton of CSS files and what surprised me most is the amount of unique master pages. There are three main master pages for SharePoint 2010 (v4.master, minimal.master, mwsdefaultv4.master). The main three CSS files are (COREV4.CSS, controls.css, search.css).

Server Side Files: Number
Images 2,950
CSS Files 98
Master Pages 30
Publishing Page Layouts 16

Template Details: The standard templates that come with SharePoint are majority collaboration/content based templates and meeting workspaces.

Template Details: Number
Site Templates 26
List Templates 14
Library Templates 8

Font Family: It is interesting to see that majority of all fonts in SharePoint 2010 are Verdana and Tahoma. There is really no elements that use Arial at all.

Font-Family Corev4.css: Number
verdana 41
tahoma 16
Segoe UI 8
sans-serif 1
Other 12

Font Size Types: This to me was very surprising. There are 68 instances of “PT” used just within the corev4.css file.

Size Type Corev4.css: Number
PX 969
PT 68
EM 72
% 63

Font Sizes: Majority of all of the font sizes used are 8pt. The second largest is the 1em which is equal to the 8pt specified as the base font size on the body within the corev4.css file.
body{
font-size:8pt;
}

Font-Size Corev4.css: Number
8pt 47
1em 20
1.3em 7
1.1em 6
10pt 5
11pt 4
1px 4
1.4em 4
16pt 1
inherit 1
Other 30

Base Colors: This was hard to track real good numbers as there was no good way of finding all of the top used colors. What you get out of the bottom table is that all of the main base colors are either dark or light blue. The main hyperlink color is the “#0072BC” color.

Colors Corev4.css: Number
transparent 85
#FFF (White) 83
#0072BC (Light Blue) 41
#000000 (Black) 34
#FFFFFF (White) 28
#003759 (Dark Blue) 24
#91cdf2 (Light Blue) 12
#83b0ec (Light Blue) 11
#3b4f65 (Dark Blue) 10
#005372 (Dark Blue) 10
#4c4c4c (Dark Gray) 10
#666666 (Dark Gray) 9
#23272c (Dark Dark Blue) 8
#6f9dd9 (Light Blue) 8
#44AFF6 (Light Blue) 7
#5d6878 (Blue Gray) 6
#003399 (Blue) 6

Display: Majority of all of the elements that are displayed are inline-block or block. It is interesting that over 20 elements are using the display:none element. This might be because of things that use JavaScript to add in inline CSS to make the what was hidden element visible. Such as drop down menus or other dynamic elements.

Display Corev4.css: Number
inline-block 56
block 46
none 21
inline 13
table 1

Float: The stats on floating elements give you the impression on how many elements are floating and could have potential display issues with your custom branding.

Float Corev4.css: Number
left 39
right 18
none 6

Position: There are more absolute positioned elements than relative.

Position Corev4.css: Number
absolute 22
relative 19
fixed 2
static 1

Image Types: As noted below, GIF files still lead the pack in file types but PNG files are making a strong upswing due to better browser support, transparencies, color values, and file size. I am pretty surprised to still see BMP files in the list.

Image Details: Number
GIF 2,026
PNG 883
JPG 24
ICO 11
BMP 4

Image Sizes: I am happy to see that majority of all of the images used in SharePoint are below 10KB. There is one that is 26qkb but has many icons included in it (formatmap32x32.png).

Image Size Details: Number
0-10 KB 2,852
10-100 KB 96
250 KB + 2

Overall SharePoint 2010 has come a long way of updating the CSS, Images, and files to get them to the 21 century. However there are still a lot of changes that I would like to see in SharePoint 2015.