I can see the idée behinde you answer, but the syntax dont work, i cant finde out to do it right, havde search for some hours now, and cant finde anything on whats wrong,
Idea is simple check if next item has same year, if not write year
of course, substring is in bad place try this
<>
test="substring(data [@alias = 'mydate'],7,4) != substring(following-sibling::node/data [@alias = 'mydate'],7,4)">
Thank you again Petr for takeing the time to help me :-)
The syntax worked, but it look at bit funny the result, after doing some debuging i finde out that following-sibling dont care about my sort, it just look at the next node, is there any way to make it use my sort?
Using the following-sibling method is a bit taxing on the process, but works fine for small datasets. If you are working with a larger site with a lot of nodes, consider looking into the muncheon (key) method.
Sorting in groups of years.
Hey guys, i am totally new to umbraco and XSL, but hope someone here can tell me how i go about this.
I have many news items, that get liste after date, what i like is getting them group in years so the output looks like this
---------2009---------
news items
news items
news items
news items
---------2008---------
news items
news items
--------2007-----------
news items
news items
and os on.....
am i doing this with "if" or "sort"? here is my simpel code so far:
Hope someone can point me the right way :-)
It sorts alphabetically,
try look here http://www.xml.com/pub/a/2002/07/03/transform.html?page=2
in short
Petr
Great ty.. :-) i can use that code to get the year out.
Now i just need to finde out how to put the "Year
" before the year start of a new year..
something like..
[code]
[/code]
but how do i use variable and chance them in XSL
You should use following-sibling axes
something like (from head, not testted)
test="substring(data [@alias = 'mydate'],7,4) != following-sibling::node/substring(data [@alias = 'mydate'],7,4)">
Thanks Petr
I can see the idée behinde you answer, but the syntax dont work, i cant finde out to do it right, havde search for some hours now, and cant finde anything on whats wrong,
when i put this line in, umbraco cant save:
following-sibling::node/substring(data [@alias = 'mydate'],1,4)"
i dont get any errors just "Xslt file could not be saved"
Idea is simple check if next item has same year, if not write year
of course, substring is in bad place try this
<>
test="substring(data [@alias = 'mydate'],7,4) != substring(following-sibling::node/data [@alias = 'mydate'],7,4)">
Thank you again Petr for takeing the time to help me :-)
The syntax worked, but it look at bit funny the result, after doing some debuging i finde out that following-sibling dont care about my sort, it just look at the next node, is there any way to make it use my sort?
Hi, I'm not sure about sort and xpath axes, so let's try something different - position()
First add all nodes to variable
change
After a long time trying to get code working, it looks the same as last time, i think it dont use my sort. :(
Ty Petr. for all the help, even if we did not get threre o:)
I think is really werid that this i something so hard to do in XSL, if i was just able to save a variable.......
Hi, it should work, it test actual node with next node, it should be placed after processing actual node.
But if you have problem working with xslt, you can use c#, where you can save variable
http://www.umbraco.org/4634
Petr
Or take look at this post, there is a solution
http://forum.umbraco.org/yafpostst8654XSLT-count-distinct-values.aspx?find=unread
Using the following-sibling method is a bit taxing on the process, but works fine for small datasets. If you are working with a larger site with a lot of nodes, consider looking into the muncheon (key) method.
Case
The Munchean method is applied in this Umbraco snippet:
http://blackpoint.dk/umbraco-workbench.aspx?Snippet=/umbraco-workbench/xslt/grouping--distinct-values.aspx
Thanks alot guys.. :d/
the blackpoint.dk did the trick, just as i neede - it was really easy to use for a newbi like me...
Take care
is working on a reply...