Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have made the following structure.
NodeX + Project - Items - Items + Project - Items - Items
Each project has a thumbnail and each item has two enlargements called large and largedetail.
I want to generate a list of thumbnails to be displayed on NodeX.I also want to generate a list of the large items with a href (fancybox) on it which displays largedtail.
The for-each loop isn't a problem, but displaying the different fields is.BTW, another question, does a for-each loop always loop in the order which is given on the backend?
Any help is appreciated.
To start at the bottom: You can shove a sort instruction inside a for-each to specify the sort order, e.g.:
<xsl:sort select="@sortOrder" data-type="number" order="ascending" />
<!-- Do something -->
In the sort's select attribute you can specify an XPath expression, which can be as simple as an attribute (as in this example) or a complex calculation.
The best way to do something like this is actually to create a template for a single Project and instead of using for-each, use the apply-templates instruction - short sample here:
<?xml version="1.0" encoding="utf-8" ?>
<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="projectsRoot" select="$siteRoot/Projects" /><!-- Select NodeX here -->
<xsl:sort select="@nodeName" data-type="text" order="ascending" />
<h1><xsl:value-of select="@nodeName" /></h1>
Project details ...
As you can see, the apply-templates instruction enables you to extract the Project markup (so it doesn't have to live inside the for-each) so it's easier to maintain (and re-use).
Once you get this working you'll be able to start tweaking. If you already have the complete HTML for a Project it should be quite easy to start picking the dynamic parts from within the template.
Hope this helps ...
It helps, but I'm not there yet.
What's still a problem is the following.Item is a child of Portfolio, a child has an image with the alias display.It seemed logic to me to loop through alle Items like coded below.Regard my point of origin from where xslt is running is the node above Portfolio.
I hope I've epxlained it a bit more like this.Please any help on what I'm doing wrong
<xsl:for-each select="$currentPage/ancestor-or-self::root//Portfolio/Item"> <li> <xsl:variable name="media" select="umbraco.library:GetMedia(display, 'false')" /> </li> </xsl:for-each>
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted