I am very new to Umbraco and trying to implement a concept similar to an Article list that a lot of the starter kits have.
I am trying to create an XSLT that displays a profile of a rider.However I have seemed to have put something wrong in my code because on the first picture is being display.I have a problem in by for-each loop but can see to find where it is.
Below is my XSLT (apologizes for the mess and probably extra lines of code not needed).
Any help would be great. I have BOLDED the problem that I think but cant work out what the problem actually is.
I think the problem is that you are setting your media variable based on the $ridersProfile variable, which is set once at the top of your XSLT file. I think you instead want to read it from the current node in the for-each loop, correct?
GetMedia not looping correctly
Hello,
I am very new to Umbraco and trying to implement a concept similar to an Article list that a lot of the starter kits have.
I am trying to create an XSLT that displays a profile of a rider. However I have seemed to have put something wrong in my code because on the first picture is being display. I have a problem in by for-each loop but can see to find where it is.
Below is my XSLT (apologizes for the mess and probably extra lines of code not needed).
Any help would be great. I have BOLDED the problem that I think but cant work out what the problem actually is.
Thanks
-----XSLT Code-----
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:PS.XSLTsearch="urn:PS.XSLTsearch"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets PS.XSLTsearch ">
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:param name="currentPage"/>
<!-- Don't change this but create a 'number' element in your -->
<!-- macro with the alias of 'numberOfItems' -->
<xsl:variable name="ridersPerPage" select="8" />
<xsl:variable name="ridersProfile" select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']"/>
<xsl:variable name="panel" select="umbraco.library:GetXmlNodeById(current()/.)"/>
<xsl:variable name="contentPanel" select="umbraco.library:Split($currentPage/contentPanel,',')" />
<xsl:variable name="pageNumber" >
<xsl:choose>
<xsl:when test="umbraco.library:RequestQueryString('page') <=0 or string(umbraco.library:RequestQueryString('page')) = '' or string(umbraco.library:RequestQueryString('page')) = 'NaN'">0</xsl:when>
<xsl:otherwise>
<xsl:value-of select="umbraco.library:RequestQueryString('page')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="numberOfItems" select="count($ridersProfile)"/>
<xsl:template match="/">
<!-- The fun starts here -->
<xsl:if test="$numberOfItems > 0">
<div id="gallery_prettyphoto" class="gallery">
<ul class="gallery_4columns">
<xsl:for-each select="$ridersProfile">
<xsl:if test="position() > $ridersPerPage * number($pageNumber) and position() <= number($ridersPerPage * number($pageNumber) + $ridersPerPage )">
<li>
<xsl:variable name="media" select="umbraco.library:GetMedia($ridersProfile/profileImage,0)"/>
<xsl:if test="$media">
<a href="{umbraco.library:NiceUrl(@id)}"><img src="{$media/umbracoFile}" height="236" width="150"/></a>
</xsl:if>
<div id="riderName">
<a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>
</div>
</li>
</xsl:if>
</xsl:for-each>
</ul>
</div>
<!-- Page Per Riders Numbers -->
<xsl:if test="$numberOfItems > $ridersPerPage">
<br/>
<p id="pager">
<xsl:call-template name="pageNumbers">
<xsl:with-param name="pageIndex" select="1"/>
</xsl:call-template>
</p>
</xsl:if>
</xsl:if>
</xsl:template>
<!-- individual links to each page of results for the search -->
<xsl:template name="pageNumbers">
<xsl:param name="pageIndex"/>
<xsl:if test="$pageIndex != 1"> | </xsl:if>
<xsl:choose>
<xsl:when test="$pageIndex - 1 = $pageNumber">
<!-- current page -->
<strong>
<xsl:value-of select="$pageIndex"/>
</strong>
</xsl:when>
<xsl:otherwise>
<!-- other pages -->
<a>
<xsl:attribute name="href">
?page=<xsl:value-of select="$pageIndex - 1"/>
</xsl:attribute>
<xsl:value-of select="$pageIndex"/>
</a>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$pageIndex * $ridersPerPage < $numberOfItems">
<xsl:call-template name="pageNumbers">
<xsl:with-param name="pageIndex" select="$pageIndex + 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Hi,
I think the problem is that you are setting your media variable based on the $ridersProfile variable, which is set once at the top of your XSLT file. I think you instead want to read it from the current node in the for-each loop, correct?
Try changing to:
<xsl:variable name="media" select="umbraco.library:GetMedia(profileImage,0)"/>
This will cause the media variable to be set to profileImage from the current node in the for-each
Hope this helps,
Tom
is working on a reply...