I'm trying to work out in my head how to explain this as I write it down so please bear with me.
I have an events section of the site. I created some nodes under "LSTM Events" for each month (May, June etc.) and then each child node those that is an event for that month.
On each of the month nodes, the code I've written pulls in the data it needs to create a list of all the events going on that month in date order. The xslt for this is below:
<xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1'] [string(data [@alias='showinrss']) != '0']"> <xsl:sort select="./data[@alias='eventdate']" order="ascending" /> <hr style="border-bottom: 1px solid #ccc; margin: 20px 0px 20px 0px;" /> <h2><xsl:value-of select="./data[@alias='heading']" /></h2> <p> <strong>Date: </strong><xsl:value-of select="umbraco.library:FormatDateTime(./data[@alias='eventdate'],'dd MMM yyyy')"/> <!-- If there's no end date, don't add in the - and date --> <xsl:if test="./data [@alias='enddate'] != ''"> - <xsl:value-of select="umbraco.library:FormatDateTime(./data[@alias='enddate'],'dd MMM yyyy')"/> </xsl:if> <br /> <!-- If there's no time confirmed, remove text and time --> <xsl:if test="./data [@alias='eventtime'] != ''"> <strong>Time: </strong><xsl:value-of select="./data[@alias='eventtime']"/><br /> </xsl:if> <!-- If there's no venue confirmed, remove venue text --> <xsl:if test="./data [@alias='venue'] != ''"> <strong>Venue: </strong><xsl:value-of select="./data[@alias='venue']"/><br /> </xsl:if> <!-- If there's no location confirmed, remove location text --> <xsl:if test="./data [@alias='location'] != ''"> <strong>Location: </strong><xsl:value-of select="./data[@alias='location']"/><br /> </xsl:if> </p> <xsl:value-of select="./data[@alias='fulldescription']" disable-output-escaping="yes" /> <p> </p><!-- If there's no access confirmed, remove access text --> <xsl:if test="./data [@alias='access'] != ''"> <p><strong>Access: </strong><xsl:value-of select="./data[@alias='access']"/></p> </xsl:if> <p> </p> </xsl:for-each>
This code works fine, but I want to adapt it slightly for the following:
On the LSTM Events page, I want to put some very similar code that will select the first child node (in this case May) and then run through the code that is above - effectively making that page display the events for whatever month the first child node of LSTM Events. As a month comes to an end, I'll simply delete it from the list, and therefore the next month will be at the top.
I've tried fiddling around with the currentPage/node part but can't seem to get the syntax right..
There are two doctypes. The months and the events. The top level is using the month doctype, but I want to use a macro and xslt on that page to display all the child nodes from whatever month is listed first.
If you want to list the all month and their events, I think you could do it this way:
<xsl:for-eachselect="$currentPage//node [string(data [@alias='umbracoNaviHide']) != '1'] [string(data [@alias='showinrss']) != '0']"> <xsl:sortselect="./data[@alias='eventdate']"order="ascending"/> <hrstyle="border-bottom:1px solid #ccc; margin: 20px 0px 20px 0px;"/> <h2><xsl:value-ofselect="./data[@alias='heading']"/></h2> <p> <strong>Date: </strong><xsl:value-ofselect="umbraco.library:FormatDateTime(./data[@alias='eventdate'],'dd MMM yyyy')"/> <!-- If there's no end date, don't add in the - and date --> <xsl:iftest="./data [@alias='enddate'] != ''"> - <xsl:value-ofselect="umbraco.library:FormatDateTime(./data[@alias='enddate'],'dd MMM yyyy')"/> </xsl:if> <br/> <!-- If there's no time confirmed, remove text and time --> <xsl:iftest="./data [@alias='eventtime'] != ''"> <strong>Time: </strong><xsl:value-ofselect="./data[@alias='eventtime']"/><br/> </xsl:if> <!-- If there's no venue confirmed, remove venue text --> <xsl:iftest="./data [@alias='venue'] != ''"> <strong>Venue: </strong><xsl:value-ofselect="./data[@alias='venue']"/><br/> </xsl:if> <!-- If there's no location confirmed, remove location text --> <xsl:iftest="./data [@alias='location'] != ''"> <strong>Location: </strong><xsl:value-ofselect="./data[@alias='location']"/><br/> </xsl:if></p> <xsl:value-ofselect="./data[@alias='fulldescription']"disable-output-escaping="yes"/> <p></p><!-- If there's no access confirmed, remove access text --> <xsl:iftest="./data [@alias='access'] != ''"> <p><strong>Access: </strong><xsl:value-ofselect="./data[@alias='access']"/></p> </xsl:if> <p></p> </xsl:for-each>
The $currentPage//node is the short hand version of $currentPage/descendant/node and this XPath will retrieves all nodes below the node in reference no matter the depth.
I hope this is what you need, I haven't so much experience with Umbraco old XML schema, so I hope this can help you in some way.
Show child nodes of child node
Hi,
I'm trying to work out in my head how to explain this as I write it down so please bear with me.
I have an events section of the site. I created some nodes under "LSTM Events" for each month (May, June etc.) and then each child node those that is an event for that month.
On each of the month nodes, the code I've written pulls in the data it needs to create a list of all the events going on that month in date order. The xslt for this is below:
This code works fine, but I want to adapt it slightly for the following:
On the LSTM Events page, I want to put some very similar code that will select the first child node (in this case May) and then run through the code that is above - effectively making that page display the events for whatever month the first child node of LSTM Events. As a month comes to an end, I'll simply delete it from the list, and therefore the next month will be at the top.
I've tried fiddling around with the currentPage/node part but can't seem to get the syntax right..
Any help would be much appreciated!
Thanks,
Tom
Bump. :(
Hey Tom,
All your nodes have the same icon, does this mean they are the same DocType?
Rich
HI Rich,
There are two doctypes. The months and the events. The top level is using the month doctype, but I want to use a macro and xslt on that page to display all the child nodes from whatever month is listed first.
Thanks,
Tom
Hi Tom,
If you want to list the all month and their events, I think you could do it this way:
The $currentPage//node is the short hand version of $currentPage/descendant/node and this XPath will retrieves all nodes below the node in reference no matter the depth.
I hope this is what you need, I haven't so much experience with Umbraco old XML schema, so I hope this can help you in some way.
/Dennis
is working on a reply...