2
votes

I have the following problem. My node tree looks like this:

  • Home

    • News Area

      • News1
      • News2
    • Events Area

      • Event1
      • Event2

When you want to display it on the main site, everything is fine.

<xsl:for-each select="$currentPage/eventsArea/simpleEvent [@isDoc and string(umbracoNaviHide) != '1']">

However, this only works to find on the main page of my site. When I go to a subpage, this solution does not work anymore.

Does anyone know how to solve it?

2

2 Answers

0
votes

So I assume you want to display a list of events on every page, like on a sidebar.
To do so, instead of starting at $currentPage start at /root/home like so:

<xsl:for-each select="/root/home/eventsArea/simpleEvent [@isDoc and string(umbracoNaviHide) != '1']">

or if you want to find all simpleEvent pages regardless of where they exist do this:

<xsl:for-each select="//simpleEvent [@isDoc and string(umbracoNaviHide) != '1']">

The latter will keep working if someone changes the folder structure.

0
votes

Unfortunately, the first and the second does not work.

If the code looks like this:

<xsl:for-each select="$currentPage/eventsArea/simpleEvent [@isDoc and string(umbracoNaviHide) != '1']">
<xsl:sort select="@createDate" order="descending" />
<xsl:if test="position() &lt;= $numberOfItems">
<a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>
<p><xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(bodyText), number($excerptLength), '...')" disable-output-escaping="yes"/></p>
</xsl:if>
</xsl:for-each>

It all works as it should.

enter image description here

<xsl:for-each select="/root/home/eventsArea/simpleEvent [@isDoc and string(umbracoNaviHide) != '1']">

or

<xsl:for-each select="//simpleEvent [@isDoc and string(umbracoNaviHide) != '1']">

Do not display anything.

enter image description here