Posted: August 31st, 2010 | Author: davecavins | Filed under: General SharePoint | Tags: BCP2010, SharePoint | No Comments »
I meant to post this last week during the conference but I was too busy or too tired to do so.
So the conference started off with an hour long keynote presentation that began with short a welcome from Bill English from Mindsharp. The welcome was follow by an hour long advertisement for Microsoft’s SharePoint MCM program. Various MCM’s came up and talked about how great the program is and how much smarter they are as a result of attending it.
Overall this session was somewhat interesting but for the most part I don’t feel that it really applied to most of the audience of the conference. There are only 24 slots available for the MCM course each quarter and the training is rather expensive ($30k). Needless to say I would not have felt bad if I had come late.
The rest of the day I attended sessions by various presenters mainly focused on the new features in SharePoint 2010. I wish there had been more sessions focused on MOSS 2007 or just general best practices because although the presentations were interesting I know it will be quite some time before I will get to use SP2010 at work.
This was my first conference and it felt good to be able to learn so much from others and talk to people who are working with the same tools. I was glad to see such a diverse group of people including developers, administrators, project managers and other users.
You can read more discussion about #BPC2010 here.
I’ll write more later but right now it’s time to get back to work.
Posted: August 24th, 2010 | Author: davecavins | Filed under: General SharePoint | Tags: SharePoint | No Comments »

So I am at the Best Practices Conference here in Reston VA. I am going to try to post about what I learn and some of my opinions on the conference as a whole. This is my first time attending a SharePoint Conference so it should be interesting. I hope to learn a lot about both 2007 and 2010.
Most best practices information I have read before has been pretty good but because of the many uses ad types of SharePoint deployments it seems to be very difficult to establish many best practices that will always be true no matter the size or type of your deployment.
Posted: August 4th, 2010 | Author: davecavins | Filed under: General SharePoint, SharePoint Design | Tags: CSS, Data View Web Part, SharePoint, SharePoint Designer, ticker, xsl | 1 Comment »
A while back I did a post about how to make a vertical news ticker, in the comments several people pointed out problems with the code so I decided to write a better version of the code. Here it is.

New Ticker
For this ticker I started out with a default Annoucements list. Because I wanted to display a thumbnail for each annoucement I added a signle line of text column called Subtitle and a Picture column called Picture. Here are the columns I used.

Here is the basic structure of the ticker.
<div id="actions">
<a class="prev">« Back</a> <a class="next">More pictures »</a></div>
<div class="scrollable vertical">
<div class="items">
<div class="item">
<img src="#" alt="Thumbnail Image" />
<h3>Title</h3>
<strong>
<span>Subtitle Text</span>
</strong>
<p>First 200 Characters of the body</p>
<p><a href="#">Read more</a></p>
</div>
</div>
</div>
Below is the xsl code I used to build the ticker.
<Xsl>
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:output method="html" indent="no"/>
<xsl:decimal-format NaN=""/>
<xsl:param name="dvt_apos">'</xsl:param>
<xsl:param name="url_PATH_INFO" />
<xsl:param name="url_HTTP_HOST" />
<xsl:param name="Today">CurrentDate</xsl:param>
<xsl:variable name="dvt_1_automode">0</xsl:variable>
<xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls">
<xsl:call-template name="dvt_1"/>
</xsl:template>
<xsl:template name="dvt_1">
<xsl:variable name="dvt_StyleName">Table</xsl:variable>
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
<script>
$(function() {
$(".scrollable").scrollable({ vertical: true, mousewheel: true, circular: true, keyboard: true });
// scrollable has to match the class on the div you use to wrap your items.
});
</script> <div id="actions">
<a class="prev">« Back</a>
<a class="next">More pictures »</a>
</div>
<div class="scrollable vertical">
<div class="items">
<xsl:call-template name="dvt_1.body">
<xsl:with-param name="Rows" select="$Rows"/>
</xsl:call-template>
</div>
</div>
</xsl:template>
<xsl:template name="dvt_1.body">
<xsl:param name="Rows"/>
<xsl:for-each select="$Rows">
<xsl:call-template name="dvt_1.rowview"/>
</xsl:for-each>
</xsl:template>
<xsl:template name="dvt_1.rowview">
<div class="item">
<xsl:if test="not(normalize-space(@Picture) = '')"><img src="{substring-before(@Picture,',')}" /></xsl:if>
<h3><xsl:value-of select="@Title"/></h3>
<strong>
<xsl:if test="not(normalize-space(@SubTitle) = '')"><span><xsl:value-of select="@SubTitle " disable-output-escaping="yes" /></span></xsl:if>
</strong>
<p><xsl:value-of select="substring(@Body,0,200)" disable-output-escaping="yes" /></p>
<p><a href="http://{$url_HTTP_HOST}/{@FileDirRef}/DispForm.aspx?id={@ID}">Read more</a></p>
</div>
</xsl:template>
</xsl:stylesheet></Xsl>
If you try to run the page with just this XSL it will give an error. You will also need to add these two lines to the parameter bindings section of your dataview web part. I used these 2 parameters to get the URL of the current page in order to built the ‘read more’ link. This is what I would call a best practice because other wise you would have to hard code the URL to your site which makes it harder for others to use your code.
<ParameterBinding Name="url_PATH_INFO" Location="ServerVariable(PATH_INFO)" DefaultValue=""/><ParameterBinding Name="url_HTTP_HOST" Location="ServerVariable(HTTP_HOST)" DefaultValue=""/>
In addition to this code you will also need to add links to these two files.
<script src="http://cdn.jquerytools.org/1.2.3/jquery.tools.min.js"></script>
/* css file to style the ticker */
<link rel="stylesheet" type="text/css" href="scroll.css" />
Here is the css I used to style my ticker.
/* root element for scrollable */
.vertical {
/* required settings */
position:relative;
overflow:hidden;
/* vertical scrollers have typically larger height than width */
height: 665px;
width: 700px;
border-top:1px solid #ddd;
}
/* root element for scrollable items */
.items {
position:absolute;
/* this time we have very large space for height */
height:20000em; margin: 0px;
}
/* single scrollable item */
.item {
border-bottom:1px solid #85b1ee;
border-top:1px solid #85b1ee;
margin:10px 0; padding:15px; font-size:12px;
height:180px; background:#d6e8ff;
}
/* elements inside single item */
.item img {
float:left;
margin-right:20px;
height:180px;
width:240px;
border:5px solid #fff;
}
.item h3 {
margin:0 0 5px 0;
font-size:16px;
color:#4a6499;
font-weight:normal;
}
.item p a{padding:3px;}
.item p a:hover{ background:#fff; text-decoration:none;}
.item p { padding:3px; margin:5px;}
/* the action buttons above the scrollable */
#actions { width:700px; margin:30px 0 10px 0;}
#actions a {font-size:11px; cursor:pointer; color:#666;}
#actions a:hover {text-decoration:underline; color:#000;}
.disabled {visibility:hidden;}
.next {float:right;}
Notes
- The XSL is setup so that if no thumbnail is provided it will automatically adjust. The same is true if no subtitle is entered. This is done using conditional formating.
- Only the first 200 characters of the body are shown. To change this amount you can just change this line of code xsl:value-of select=”substring(@Body,0,200)”.
- You do not need the whole jQuery library in order for this to run.
Resources
Posted: June 14th, 2010 | Author: davecavins | Filed under: General SharePoint, SharePoint Design | Tags: CSS, SharePoint, SharePoint Designer, theme | No Comments »
So in part one of this post we got all the CSS and other theme file we needed to stuck them in a document library.
With JavaScript you can change the CSS file a page uses without requiring a page refresh. I have used this technique many times on non-SharePoint sites but there are some special challenges implementing this in SharePoint. Most of the scripts I have used in the past use the alternate style sheet method as describred by A List Apart here. That method works fine but I had to find another way because I was already using that script to allow users to change the font size. After some research I found this script from CSS Newbie that worked pretty well without using alternate style sheets.
The problem
While the script works just fine on regular HTML pages it cause problems in SharePoint here is why :
$("link").attr("href",$(this).attr('rel'));
This line of code basically finds all the linked CSS files in the page and changes thier value to point to the new style sheet you select. This is fine on a site that just uses one CSS file but in SharePoint bad things happen. In most cases we dont want to completely remove the reference to core.css. For most themes many elements don’t need to be changed so we only have to write the CSS to change them and let core.css do the rest. If you remove core.css its like using a global reset (discussed in more detail here) which means you will have to restyle everything. So them point is we want to leave core.css in the page and just add our theme.
To do this I had to make some changes to the master page to create to interface users will use to swap themes.
Read the rest of this entry »
Posted: June 7th, 2010 | Author: davecavins | Filed under: SharePoint Design | Tags: CSS, SharePoint, stylesheet, theme | 1 Comment »
Many sites offer the ability for users to change the color and style of the site to fit their preference. SharePoint has this feature to some extend through themes but changing themes is not a very simple process and requires browsing to several pages.
With JavaScript you can change the CSS file a page uses without requiring a page refresh. I have used this technique many times on non-SharePoint sites but there are some special challenges implementing this in SharePoint. For this solution there were several requirements.
- Users need to be able to switch themes and have the setting saved
- No page refresh
- Should be able to use both out of the box themes and custom themes
So first I needed to get the CSS files and images for the themes I wanted to use. When you assign a theme to a site all the files for the theme are copied to a folder named _themes in the root of the site.

_themes folder
So what I did was assign each theme I wanted to use to the site one at a time. With SharePoint designer I copied the files folders for each theme into a document library called Site Styles. Each folder contains all the resources needed or the theme to work.
Here is what I ended up with

Site Styles Library
If I wanted to create a custom theme I could just add another folder with my custom CSS and images.
This same technique can be used when developing your own custom theme, just copy one that is similar to what you want and use the alternate CSS link on the master page settings page to add it to the site. Inside of the folder for each theme is a file named theme.css. Link to that file and SharePoint will apply the theme to the site.

Alternate CSS URL
Now everything we have done so far is pretty basic and easy to do but we will pull all this together with some simple edits to the master page to complete the solution. In part 2 I’ll explain how we use JavaScript to switch styles and set a cookie to remember the users theme choice.
Posted: May 3rd, 2010 | Author: davecavins | Filed under: General SharePoint | Tags: better forms, forms, jQuery, SharePoint | 2 Comments »
So I found this cool jQuery plugin that does watermarks for form inputs. Using watermarks is a good way to help make SharePoint forms easier to use. To test the plugin I started with the new item form from same test list I used in my previous posts.

Watermarks
Prerequisites
- jQuery Library referenced in the page
- CEWP on the page
Read the rest of this entry »
Posted: April 23rd, 2010 | Author: davecavins | Filed under: SharePoint Design | Tags: CSS-Tricks, javasc, SharePoint Designer, slider | No Comments »
Several people have asked how to change the under of items displayed in the slider and how to change the sort order.
Item Limit
To change the number of items displayed use the code below.
<Xsl>
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:output method="html" indent="no"/>
<xsl:decimal-format NaN=""/>
<xsl:param name="dvt_apos">'</xsl:param>
<xsl:variable name="dvt_1_automode">0</xsl:variable>
<xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls">
<xsl:call-template name="dvt_1"/>
</xsl:template>
<xsl:template name="dvt_1">
<xsl:variable name="dvt_StyleName">Table</xsl:variable>
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row" />
<xsl:variable name="RowLimit" select="3" />
<xsl:variable name="dvt_RowCount" select="count($Rows)" />
<xsl:variable name="IsEmpty" select="$dvt_RowCount = 0" />
<link rel="stylesheet" href="css/page.css" type="text/css" media="screen" />
<link rel="stylesheet" href="css/slider.css" type="text/css" media="screen" />
<script type="text/javascript" src="js/jquery.easing.1.2.js"></script> <script src="js/jquery.anythingslider.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript"></script> <div class="anythingSlider">
<div class="wrapper">
<ul>
<xsl:call-template name="dvt_1.body">
<xsl:with-param name="Rows" select="$Rows" />
<xsl:with-param name="FirstRow" select="1" />
<xsl:with-param name="LastRow" select="$RowLimit" />
</xsl:call-template>
</ul>
</div>
</div>
</xsl:template>
<xsl:template name="dvt_1.body">
<xsl:param name="Rows" />
<xsl:param name="FirstRow" />
<xsl:param name="LastRow" />
<xsl:for-each select="$Rows">
<xsl:variable name="dvt_KeepItemsTogether" select="false()" />
<xsl:variable name="dvt_HideGroupDetail" select="false()" />
<xsl:if test="(position() >= $FirstRow and position() <= $LastRow) or $dvt_KeepItemsTogether">
<xsl:if test="not($dvt_HideGroupDetail)" ddwrt:cf_ignore="1">
<xsl:call-template name="dvt_1.rowview" />
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="dvt_1.rowview">
<li>
<div class="textSlide">
<h3><a href="/{@FileDirRef}/DispForm.aspx?ID={@ID}" title="{@Title}"><xsl:value-of select="@Title" /></a></h3>
<xsl:value-of select="@Body" disable-output-escaping="yes" />
</div>
</li></xsl:template>
</xsl:stylesheet>
</Xsl>
On line 13 change the RowLimit to the number of items you would like to show. For example if you wanted to show 6 items you would change line 13 to this
<xsl:variable name="RowLimit" select="6" />
Sort Order
Changing the sort order can be done through SharePoint Designer once you are using the updated code
- Click on the arrow to show the common data view tasks.
- Click on ‘Sort and Group’ the second option.
- Make changes as needed.
If dont want to do it that way there is another option.
- Open the page in SharePoint Designer
- In code view find this ‘SharePoint:SPDataSource’ you will need to edit this tag.
- Find the SelectCommand and add/edit the OrderBy attibute.
- See the code below for an example. (Ordered by Created Date in Ascending order). Its basically a CAML query.
<SharePoint:SPDataSource runat="server" DataSourceMode="List" SelectCommand="<View><Query><OrderBy><FieldRef Name="Created_x0020_Date" Ascending="TRUE"/></OrderBy></Query></View>"
If you are not sure how to get it all set up look to my previous post on the Anything Slider. If you have questions please post a comment.
Posted: April 21st, 2010 | Author: davecavins | Filed under: General SharePoint | Tags: CSS, design, jQuery, SharePoint | 5 Comments »
Sometimes it is useful to allow users to quickly change how data is displayed. Changing the display can make is easier to see patterns or find a specific item you are looking for. With CSS and jQuery we can easily change the way content is displayed and arranged on the page. I got the idea for this post from here

Switch views using CSS and jQuery
Read the rest of this entry »
Posted: March 25th, 2010 | Author: davecavins | Filed under: General SharePoint, SharePoint Design | Tags: comments | 6 Comments »
So here is what we have done so far from Part 1
- Create a custom list to hold our comments
- Link the list with an Annoucements list using lookup columns
- Create a page to display a single annoucement and the realted comments from our comments list.
This is what it looks like:

What we have so far.
All we need to do now is setup a form on the page to allow users to create new comments on the item they are viewing.
Read the rest of this entry »
Posted: March 15th, 2010 | Author: davecavins | Filed under: General SharePoint, SharePoint Design | Tags: comments | 1 Comment »
In SharePoint 2007 the only lists that offer a comments feature are the posts list in the Blog site template. Wouldn’t it be nice to allow people to post comments on other types of lists like announcements or documents? Well after lots of trial and error I figured out how to do it.
What you will need
- Two Lists
- SharePoint Designer
- Basic knowledge of HTML
I’ll assume you already have a list setup on which you want to allow users to comment. For this example I will use a standard Annoucements list.
So the first thing we need to do is create a list to hold our comments. I just used the following columns:
- Title
- Body
- Post (lookup to main list’s ‘Title’ column)
In the main list you will need to add a column that points back to the comments list.
- Go to the list settings page and click ‘Create Column’
- Name the column ‘Comments‘ (the name does not really matter. Set the type to ‘Lookup‘
- The lookup should get information from the comments list you created. The column should be set to the lookup column in the comments list. See the screenshot below.
This column will show us the number of comments each item in our list has. Read the rest of this entry »
Recent Comments