Picture Libraries with Blackband.master or blueband.master

I came across an issue in one of my branded master pages recently. The problem was that with my system.master page turned on, the thumbnail view in the picture library would not display in the nice grid view, instead the thumbnails all displayed in a single column.

Here’s a little more information. This particular client wanted a fixed width design. Per my typical pattern, when I need a custom, fixed width, master page, I made a copy of one of the out-of-the-box versions, namely BlackBand.master, and its supporting style sheets. I began customizing from there.

I was pretty far along in my customization before I found the picture library problem. The problem had to be in one of classes I was overriding in my style sheet right? After all, this html is written out inside a web part. Wrong – A quick swap of the OOB style sheet for mine yielded a very ugly page containing the same issue.

Expletive!

OK, problem is obviously in my master page somehow. I resolve to begin swapping chunks of my master page into blackband.master until I find the breaking point. So I set the master page of my dev site to blackband.master and… Wow, that was easy, it’s broken already in the OOB stuff.

Expletive!

Is it the file system on the VM I’m using?? No: default.master – working, blackband.master – broken, default.master-working, blueband.master – broken.

Default.master

Blackband.master

So what’s different between these two master pages? A lot, but you won’t need to dig very deep, because right at the top, you’ll notice that the two fixed width master pages declare their doctype: <!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>

While the default.aspx does not declare a doctype.

If you’re reading my crappy blog, you’ve undoubtedly come across Heather Solomon’s doctype blog entry in the past.

My solution was to change the doctype tag in my master page to render in quirks mode:

<!DOCTYPE html PUBLIC “-//W3C//DTD html 4.01 Transitional//EN”>

Blackband.master with quirks mode doctype.

It fixed my picture library issue and, thankfully, did not cause too many other styling issues.

My client has a nice, homogeneous environment that is IE based. I have a feeling that this change could cause issues with other browsers.

BTW. SharePoint 2010 uses all strict, standards based rendering out of the box, so these issues shouldn’t exist there anymore.

Now, knock ‘em dead, killer.

Parent – Child Relations on Dashboards

A coworker pointed me to this blog entry today: http://blogs.msdn.com/sharepointdesigner/archive/2008/03/26/sharepoint-conference-building-a-sharepoint-designer-mashup-part-1.aspx

It explains how to use an undocumented feature of the Data View web part to filter content using a lookup field’s ID instead of its display value. There are a few scenarios where this becomes really useful. The most common one being that you want to create a dashboard that displays parent/child data on the same page. You might do this on an extra page or within a custom dispform.aspx for the parent list.

It’s oh-so-easy: In the DVWP for the child data, configure it as you always would. For the filter, base it on the lookup column and set it to a parameter where your ID will be (probably a query parameter). Then go to code view and in the CAML select statement for the child, add LookupID=&quot;TRUE&quot; to the FieldRef of your where clause.

selectcommand=”&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef LookupId=&quot;TRUE&quot; Name=&quot;Supplier&quot;/&gt;&lt;Value Type=&quot;Text&quot;&gt;{SupplierID}&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;/View&gt;”

I can’t believe I’ve never run across this tip before. It would have made my life easier on a number of occasions. Thanks, Jason C.

P.S. I love this game.

Content Query Web Part XSL Tip

Today I thought I’d finally get around to posting this XSL tip for working with the content query web part.

Way back, when I started working with this web part, I found this blog entry from Mark Arend, that came in very handy for content query web part customization:  http://blogs.msdn.com/markarend/archive/2007/11/08/xsl-tips.aspx

 

I’ve since modified the xsl template slightly so that values are displayed next to the variable names. I use this xsl every time I start a new content query web part configuration.

 

<xsl:template name=”FieldIdentifier” match=”Row[@Style='FieldIdentifier']” mode=”itemstyle”>

        <table>

            <tr>

                <td>——————–</td>

            </tr>

            <xsl:for-each select=”@*”>

                <tr>

                    <td>

                 <xsl:value-of select=”name()” /> – <xsl:value-of select=”.” />

             </td>

                </tr>

            </xsl:for-each>

        </table>

    </xsl:template>

Cool SP Designer Shortcut

Did you know that SharePoint Designer has a right click menu item that allows you to preview a page in multiple browsers?

I had accidently closed my browser while working on a new contacts page in Designer. Instead of navigating back to the contacts page I knew I could right click the page in Designer and click Preview in browser to launch IE back to that page automatically. However, I then noticed the Preview in Multiple Browsers item. When I clicked that, it not only launched IE to the selected page, it also launched FireFox to that page.

I’m not sure how I’ve not seen this before, but it’s pretty cool.

I’m wondering if you have a third browser, like Google’s Chrome, if it would also open that one.

Easy XML Formatting Dates and Numbers

If you work with the Content Query web part and do a lot of custom displays, you’ve been introduced to the fact that getting fields such as numbers and dates formatted is a pain in the arse. You’ve probably also noticed that if you use the dataview web part from SPDesigner to layout your data these challenges don’t exist. In fact, this kind of formatting in the dataview web part is dead simple.

In the dataview setup in SPDesigner, you can do things like take the start time (ugly format)

And drop it in a column

Then, use the > menu, change its formatting to date time.

Which gives you a world of easy formatting options

Nice.

If you are working with a number, the same steps apply, but you are given a fantastic set of number formatting options

Check boxes, rich text, hyperlinks – all these can be chosen from the > menu.

You can then go to the code view and see the formatting formulas

<xsl:value-of select=”ddwrt:FormatDateTime(string(@EventDate) ,1033 ,’M/d/yy ‘)” />

<xsl:value-of select=”format-number(@ID, &quot;$#,##0.00;-$#,##0.00&quot;)” />

 

However, you can’t always copy the .xsl formula over to use in your Content Query xsl because the formula’s namespace isn’t in the content query’s xsl. To make the data format work, add this to the top of the .xsl where you use the formula:

xmlns:ddwrt=http://schemas.microsoft.com/WebParts/v2/DataView/runtime

For example, I used the formula in a custom version of the Main.xsl, so the top of my Main.xsl file looks like this: