1

So I have .css and .xsl code turning an out of the box SP calendar list into a pretty events list. I have a different image for each month and my code is long but works perfectly.

I also have a choice column on the list of "category" that's options are either "Birthday" or "Work Anniversary". I want to be able to filter the list to show upcoming events for just one or the other.

I cannot do this using out of the box SP view filters because every item is recurring which is a known problem for filtering upcoming events. I can have the webpart view use the out of the box "Current Events" view to show upcoming ones, but cannot filter it by either category. I can also create list views for each category, but cannot show the upcoming events because recurring events have unusual start and end dates.

Anyway. I'm already applying XSL to the list view web part and figured it would be easy to apply a simple "only show if category=birthday". I've tried to find online where to add this but as I am new to xml I'm a bit confused.

I've adding the variable Category and tried using an If statement around the whole choose section, then having the else everything again. But I couldn't make that work. Tried embedding another choose function so choose the category then choose the month but again I must have been doing something wrong.

I've seen online that at the very start I can just say for each simple select rows and include a deliminator (?) which will only bring the rows I need. So I'd like you help to implement that from the start.

Below is the top chunk of my code at the moment where I tried to add the square brackets in:

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

<xsl:template match="/">
 <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
 <xsl:variable name="Category" select="@Category"/>
 <table class="Ctable" width="200" border="0" cellspacing="0" cellpadding="0">


<xsl:for-each select="$Rows[Category='Birthday']">
<xsl:call-template name="KimRowView" /> 

</xsl:for-each>

I've added the variable and the square brackets after "

It was originally this which works but isn't filtered:

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

<xsl:template match="/">
 <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
 <table class="Ctable" width="200" border="0" cellspacing="0" cellpadding="0">

    <xsl:for-each select="$Rows">
    <xsl:call-template name="KimRowView" /> 

    </xsl:for-each>

  </table> 
</xsl:template>


<xsl:template name="KimRowView">
    <xsl:variable name="dateStrA" select="@EventDate"/>
    <xsl:variable name="CDescription" select="@description"/>
    <xsl:variable name="dayYearA" select="substring-after($dateStrA,'/')"/>      
    <xsl:variable name="dateStrB" select="@EndDate"/>
    <xsl:variable name="dayYearB" select="substring-after($dateStrB,'/')"/>  
    <xsl:variable name="CDay" select="substring-before($dateStrA,'/')"/>
    <xsl:variable name="CMonth" select="substring-before($dayYearA,'/')"/>
    <xsl:variable name="CSTENDa" select="substring($dayYearA,8)"/>
    <xsl:variable name="CSTENDb" select="substring($dayYearB,8)"/>
    <xsl:variable name="StartDate" select="substring-before($dateStrA,' ')"/>
    <xsl:variable name="EndDate" select="substring-before($dateStrB,' ')"/>
    <xsl:variable name="Age" select="substring-before(@Age,' ')"/>

    <tr>
    <td rowspan="2" class="cmonth" >           
     <div id="DBlock" >

<xsl:choose> 

    <xsl:when test="$CMonth = '01'">
      <table class="CMback" border="0" cellspacing="0" cellpadding="0">
            <tr>
            <td class="CMpic"><img src='/SiteAssets/branding/001.png' border="0"/></td>
            </tr>
            <tr>
            <td  class="CDay"><xsl:value-of select="$CDay"/></td>
            </tr>
        </table>

    </xsl:when>
    <xsl:when test="$CMonth = '02'">
      <table class="CMback" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td class="CMpic"><img src='/SiteAssets/branding/002.png' border="0"/></td>
        </tr>
        <tr>
          <td class="CDay"><xsl:value-of select="$CDay"/></td>
        </tr>
    </table>

    </xsl:when>

... blah blah 'when' for each month.

</xsl:when>

<xsl:otherwise>

    <table class="CMback" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td class="CMpic"><img src='/SiteAssets/branding/012.png' border="0"/></td>
        </tr>
        <tr>
          <td  class="CDay">Please Enter Month</td>
        </tr>
    </table>

    </xsl:otherwise>    
 </xsl:choose>        

    </div>
    </td>
    <td class="CTitle"><xsl:value-of select="@Title"/>
        </td>
        </tr>
        <tr>
        <td class="CSTEND"><xsl:value-of select="@Age"/>
    </td>
    </tr>  
</xsl:template>

How can I correct that first section so that my list is filtered by category?

I really appreciate any help or suggestion on how to achieve my goal.

Kind regards Kim

Displays as: (I highlighted part of title that is same as category, and scribbled out names) enter image description here

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.