Daily Dilbert Webpart for SharePoint

I was recently asked about a Daily Dilbert web part that someone wanted to include on a SharePoint "My Site". This thing was being distributed as a solution to be installed by an administrator. I'm not sure why that would be and I had no interest in researching it further since the answer was about 30 minutes away.

First thing I did was to add an XML Viewer webpart. In the XML Link field I entered the URL for the official feed (http://feed.dilbert.com/dilbert/daily_strip). The next 29 minutes was allocated towards coming up with some basic XSL. This is where I landed.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output indent="yes" method="html" />
  <xsl:template match="/">

      #tddMain h1 {padding:4px;margin:5px 0;background-color:#eee;color:#333;font-size:9px;}
      #tddMain img {width:100%;-ms-interpolation-mode:bicubic;image-rendering:optimizeQuality;}
      #tddMain p {display:none;}

    <xsl:variable name="ComicLink" select="rss/channel/item/link" />

    <div id="tddMain">
        <xsl:value-of select="rss/channel/item/title" />
      <a href="http://draft.blogger.com/{$ComicLink}" target="tdd">
        <xsl:value-of disable-output-escaping="yes" select="rss/channel/item/description" />

A couple points of interest relating to the CSS.

First, the comic will scale itself based on the width of the container. Thus if it's shown at full column width, it will be huge or if it's shown in a sidebar, it could be very tiny. In the Appearance section of the webpart properties, you can set a fixed width if you want to exert some control over that behavior. Or adjust the CSS, of course.

Next, you'll notice that there is a display:none associated with paragraphs. The feed includes some advertising and wraps that in paragraph tags. The only reasons I'm hiding those are because they were not displaying anything and they were causing the browser (IE9) to do some very strange things. If I can figure out a way to include the ads, I will do so and follow up here.


  1. I found decent information in your post about this. I am fascinated with your work and capacity. Thankful to you. Xml Formatter


Post a Comment