Trying to create an events module that uses categories from a checkboxlist. Currently, I have the following code:
<xsl:variable name="numberOfArticles" select="count($currentNode/descendant::node//node [@nodeTypeAlias = $itemTemplate and umbraco.library:FormatDateTime(data [@alias=$itemStartDateTime], $requestedMonthYearFormat) = $formattedRequestDate])" />
<xsl:choose>
<xsl:when test="$numberOfArticles = 0">
<li>
<h3>No Events to Display</h3>
<p>The section you are viewing contains no events.</p>
</li>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="$rootNode/descendant-or-self::node//node [@nodeTypeAlias = $itemTemplate and umbraco.library:FormatDateTime(data [@alias=$itemStartDateTime], $requestedMonthYearFormat) = $formattedRequestDate]" mode="listing">
<xsl:sort order="ascending" select="data[@alias = $itemStartDateTime]" data-type="text"/>
</xsl:apply-templates>
<img src="../images/level2/divider_dotted_short.gif" width="416" height="10" align="middle" class="divdot"/>[<a href="#top" class="backToTop">Back to top</a>] <br />
</xsl:otherwise>
</xsl:choose>
This works great to create the events module without using the categories. To see if the event has the correct categories, I use the following code within the listing template:
This also works. The problem is that I use the count on the page and it currently counts for all of the items, and then filters out the categories that don't work. Ie. The count may be 10 articles while the actual page may only display 4 articles.
Can anyone think of a way to merge these together so that the count and in term the select statement on the apply-template only display the items that meet the criteria of template, date, and categories?
You have a lot going on in all those xpaths! Not 100% sure what you are after but I suggest you break it all down into something a bit more managable by creating various temp variables for each of your steps. Something like this (not tested and its late in the day!) :
You might have to do some msxml:node-set() wrapping around some of your variables and I'm not 100% sure what you are doing with your paging but you can see I made a start on clearing up that logic too, makes the code so much more readable and debuggable.
Give me some more info on how you want to use it and I might be able to narrow it down for you but should give you some clues if you are asking for what I think you are asking for?
Trying to create a complex apply-template.
Trying to create an events module that uses categories from a checkboxlist. Currently, I have the following code:
This works great to create the events module without using the categories. To see if the event has the correct categories, I use the following code within the listing template:
This also works. The problem is that I use the count on the page and it currently counts for all of the items, and then filters out the categories that don't work. Ie. The count may be 10 articles while the actual page may only display 4 articles.
Can anyone think of a way to merge these together so that the count and in term the select statement on the apply-template only display the items that meet the criteria of template, date, and categories?
Thanks.
You have a lot going on in all those xpaths! Not 100% sure what you are after but I suggest you break it all down into something a bit more managable by creating various temp variables for each of your steps. Something like this (not tested and its late in the day!) :
You might have to do some msxml:node-set() wrapping around some of your variables and I'm not 100% sure what you are doing with your paging but you can see I made a start on clearing up that logic too, makes the code so much more readable and debuggable.
Give me some more info on how you want to use it and I might be able to narrow it down for you but should give you some clues if you are asking for what I think you are asking for?
Cheers
Pete
is working on a reply...