Each album document type contains a text field with an alias 'AlbumProject'. What I want to do is pull all distinct values of 'AlbumProject' into a list.
Hi Dan, I think I would go for the key/id approach where you generate keys for identical values. Check out this page for more info - it's a bit hairy if you are not already familiar with keys and id's, but it is extremely powerful and fast
Thanks Tommy, that's going to be a 'challenge' for my limited skills. I'll certainly look into it though. In the meantime, I can live without the 'distinct' part of the requirement, but even this doesn't return anything:
Oh, and if you need help with the grouping, let me know and I can try to get you something for that...that will probably be your best approach for distinct output...
Thanks Nik. It's looping through now (it outputs two list items and I know there are two album nodes, so that follows) but the values are empty, so it's just returning <li></li><li></li>.
Can you confirm that the child nodes of the 'source' node in fact have that property? Is AlbumProject an property of a documentType or a documentType itself?
There is at least one scenario where the above wouldn't produce any output: If the first of every possible AlbumProject value is placed on a hidden node.
Could this be the case?
Then you'd need to either:
A: Include the umbracoNaviHide predicate in the key definition, like this:
Display all distinct values of a field under node
Hi,
I have a structure like this:
Gallery
- Album 1
--Image 1
--Image 2
--Image 3
-Album 2
- Image 4
- Image 5
- Image 6
Each album document type contains a text field with an alias 'AlbumProject'. What I want to do is pull all distinct values of 'AlbumProject' into a list.
The code I have so far is:
Can anyone see how to wrap this up and get the value from the select into the list?
Thanks all...
I've updated it to set the value of the select, but it returns nothing:
There's obviously something wrong with the first line here, in the way it's searching for the nodes.
Hi Dan, I think I would go for the key/id approach where you generate keys for identical values. Check out this page for more info - it's a bit hairy if you are not already familiar with keys and id's, but it is extremely powerful and fast
http://blackpoint.dk/umbraco-workbench.aspx?Snippet=/umbraco-workbench/xslt/grouping--distinct-values.aspx
>Tommy
Thanks Tommy, that's going to be a 'challenge' for my limited skills. I'll certainly look into it though. In the meantime, I can live without the 'distinct' part of the requirement, but even this doesn't return anything:
Any ideas?
It's definitely something to do with this syntax:
How can I just select that specific data from the nodes?
Hi Dan, should be something like this:
Nik
Oh, and if you need help with the grouping, let me know and I can try to get you something for that...that will probably be your best approach for distinct output...
Thanks,
Nik
Scratch my post.... here's what you are trying to do...
Sorry...
Thanks Nik. It's looping through now (it outputs two list items and I know there are two album nodes, so that follows) but the values are empty, so it's just returning <li></li><li></li>.
Can you confirm that the child nodes of the 'source' node in fact have that property? Is AlbumProject an property of a documentType or a documentType itself?
Thanks,
Nik
The child nodes of the source node contain a text field with the alias 'AlbumProject'.
My bad! Typo. Thanks Nik, that's sorted the initial thing out - now I just need to get to grips with making it distinct.
Hi Dan
If you wanna give the key/id approach a go, its something like this - out of my head:
- but I can try to test it out later if you cannot work it out.
>Tommy
Thanks for this Tommy, I've now got the following:
But it's not outputting anything. Can you see a reason this isn't working?
Hi Dan,
There is at least one scenario where the above wouldn't produce any output: If the first of every possible AlbumProject value is placed on a hidden node.
Could this be the case?
Then you'd need to either:
A: Include the umbracoNaviHide predicate in the key definition, like this:
or B: Exclude it from the select, and handle it inside the for-each statement instead:
Hi Dan, do you get any output if you remove the generate-id clause
[generate-id() = generate-id(key('mykey', data [@alias = 'AlbumProject'])[1])]
?
>Tommy
is working on a reply...