Skip to content

Instantly share code, notes, and snippets.

@greystate
Created November 11, 2011 08:03
Show Gist options
  • Save greystate/1357476 to your computer and use it in GitHub Desktop.
Save greystate/1357476 to your computer and use it in GitHub Desktop.
Find pages changed since $startDate (XSLT)
<?xml version="1.0" encoding="utf-8" ?>
<!--
Macro to find Umbraco pages changed since $startDate
Could even be used with uComponents' RenderMacro DataType to be viewable in Backoffice.
(Works with either of the Umbraco XML Schema formats)
-->
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:umb="urn:umbraco.library"
exclude-result-prefixes="umb"
>
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
<xsl:param name="currentPage" />
<xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
<xsl:variable name="nodesToSearch" select="$siteRoot//*[@isDoc] | $siteRoot//node" />
<xsl:variable name="startDate" select="'2011-11-01T12:00:00'" />
<xsl:template match="/">
<xsl:apply-templates select="$nodesToSearch[umb:DateGreaterThanOrEqual(@updateDate, $startDate)]" />
</xsl:template>
<xsl:template match="node | *[@isDoc]">
<p>
<xsl:value-of select="@nodeName" />
<xsl:text /> (<xsl:apply-templates select="." mode="editLink" />)<xsl:text />
</p>
</xsl:template>
<xsl:template match="node | *[@isDoc]" mode="editLink">
<a href="/umbraco/editContent.aspx?id={@id}" title="Click to edit...">Edit</a>
</xsl:template>
</xsl:stylesheet>
@greystate
Copy link
Author

Because that way, it can be distributed in a sample XSLT to go with that package I was talking about that basically did what RenderMacro does. Someone using the XSLT can implement their own "View" for the nodes, and if needed generate an "Edit this node" link just by using the "editLink" mode...

Also easier to bulk update all editlinks generated throughout that file if/when that URL should ever change...

@leekelleher
Copy link

Cool, I dig that! (Why do I keep looking for a "Like" button on comments these days? Bloody Facebook!!!)

@greystate
Copy link
Author

Chriztian Steinmeier (@greystate) LOL'ed Lee Kelleher's (@leekelleher) Like of Chriztian Steinmeier's (@greystate) Comment on Chriztian Steinmeier's Gist (https://gist.github.com/1357476)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment