<xsl:param name="currentPage"/> <!-- 'source' of the children to list --> <xsl:variable name="source" select="/macro/source"/>
<xsl:template match="/">
<xsl:choose>
<!-- Here i need to test if the children of $source/children/@ultimatepickerid match $currentpage/@id-->
<xsl:when test="count(umbraco.library:GetXmlNodeById($source)/* [@isDoc]) > 0"> <ul> <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:for-each> </ul> </xsl:when> <xsl:otherwise> <li> <li> There are currently no job openings in <xsl:value-of select="relatedCountry"/>. <a href="/en/jobs">Browse all jobs</a>. </li> </li> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>
Can anyone give an example of how to match this? I need to do it in the choose statement because i want to eliminate the empty UL element if there are no matches, and give alternative out ("there are currently no jobs...")
<!-- Don't change this, but add a 'contentPicker' element to --> <!-- your macro with an alias named 'source' --> <xsl:variable name="source" select="/macro/source"/>
<xsl:template match="/"> <a href="/en/jobs" class="jobstitle">Related Jobs</a> <xsl:choose> <xsl:when test="count(umbraco.library:GetXmlNodeById($source)/* [@isDoc and relatedCountry = $currentPage/@id]) > 0 and string(umbracoNaviHide) != '1'"> <ul> <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and relatedCountry = $currentPage/@id and string(umbracoNaviHide) != '1']"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:for-each> </ul> </xsl:when> <xsl:otherwise> There are currently no job openings in <xsl:value-of select="$currentPage/@nodeName"/>. <a href="/en/jobs">Browse all jobs</a>.
xslt: how to check if any child from a set source has children with a certain propertyvalue ?
Another more challenging xslt question for me, i'm trying to relate jobs to country pages (under Network)
I need to list all children of "jobs" on the country pages (under network), if their "relatedCountry" matches $currentpage/id
I was thinking along these lines, but got stuck:
Can anyone give an example of how to match this? I need to do it in the choose statement because i want to eliminate the empty UL element if there are no matches, and give alternative out ("there are currently no jobs...")
maybe something along these lines should return a count of children with matching property relatedcountry?
<xsl:value-of select="count(umbraco.library:GetXmlNodeById($source)/* [@isDoc and @relatedCountry = '0'])"/>
Found this solution:
Thanks to this topic: http://our.umbraco.org/forum/developers/xslt/9587-Count-number-of-posts-with-category-selected
is working on a reply...