<!-- get the media XML and assign it to a variable --> <xsl:variable name="media" select="umbraco.library:GetMedia(number(data[@alias='pollpicture']), 0)" /> <!-- check if the media XML contains an image path 'umbracoFile' --> <xsl:if test="count($media/data[@alias='umbracoFile']) > 0"> <div style="width:30px; padding-top:5px;">
yeh just tried that one - but problem with identical votes persists.
i got a user control that posts a poll with the values.
the pictures are placed in a macro beside these polls. and what im trying to do is to match them in position.
but when the values are identical now - the pictures (with identical votes) get posted in a wrong order compared to the poll next to it - thats also sorted by highest value first?. unsure if there are other things its sorting by - can i add more sorting options ? - so it sorts by value primarily - and secondarily name? nodeid? etc etc ?
Got pictures with a value - wanna sort them by their value
Hello
i have a page that contains some pictures. these pictures need to be posted in a specific order
each picture has a Value <votes> and i wish to sort them from highest <votes> to lowest.
i tried fiddling alittle - but im terrible with xsl.
here is my code so far
<xsl:for-each select="umbraco.library:GetXmlNodeById(1332)/node [string(data [@alias='umbracoNaviHide']) != '1']">
<xsl:if test="data[@alias='pollpicture'] != ''">
<!-- get the media XML and assign it to a variable -->
<xsl:variable name="media" select="umbraco.library:GetMedia(number(data[@alias='pollpicture']), 0)" />
<!-- check if the media XML contains an image path 'umbracoFile' -->
<xsl:if test="count($media/data[@alias='umbracoFile']) > 0">
<div style="width:30px; padding-top:5px;">
<img style="width:30px;" src="{$media/data[@alias='umbracoFile']}" />
</div>
</xsl:if>
</xsl:if>
</xsl:for-each>
they all have a value "votes" which they need to be sorted too.
any suggestions would be helpfull
Hi Jan,
You can use the XSLT sort method to order your results by Vote.
The link below has a simple example of sorting using XSLT with umbraco.
http://en.wikibooks.org/wiki/Umbraco/Various_useful_XSLT_methods_in_Umbraco
Best of luck
Rich
hm that did something but it messes it up -
The type im using is numeric.
if i type in the votes as such
4
3
2
1
it shows everything like i want it. the highest value in the top.
but when i tried it like such
4
3
1
11
it put my highest value in the bottom? this is what i wrote out
<xsl:sort select="data [@alias = 'votes']" order="descending"/>
is there a way to make it sort it by highest numerial value ? right now it seems like its sorting them with what it begins with.
Hi,
use this:
<xsl:sort select="data [@alias = 'votes']" data-type="number" order="descending"/>
HTH,
Peter
yeh just tried that one - but problem with identical votes persists.
i got a user control that posts a poll with the values.
the pictures are placed in a macro beside these polls. and what im trying to do is to match them in position.
but when the values are identical now - the pictures (with identical votes) get posted in a wrong order compared to the poll next to it - thats also sorted by highest value first?. unsure if there are other things its sorting by - can i add more sorting options ? - so it sorts by value primarily - and secondarily name? nodeid? etc etc ?
getting close to a solution :D j
You can add multiple XSLT sort values to get what you need :)
http://www.programmersheaven.com/2/FAQ-XML-Sort-XML-By-Multiple-Attributes-XSLT
Rich
how do i sort values from a usercontrol ?
is working on a reply...