I am creating a photo website that runs online competitions. There is to be voting for the competitions that I intend storing within fields on the node. So the pseudo data structure will look like:
Initially I was intending to add another field (totalScore) and have an event handler to loop through and perform the calculation and store the total. The resulting XSLT output could then be easily sorted by the totalScore field.
But then I thought there might be a way of dynamically calculating the totals instead, but in doing so it seems that the sorting part is somewhat harder.
I prefer the latter solution as it keeps things more simple - it also reduces the potential for bugs in my code and an XSLT is easier to fix than compiled code. :-)
However I guess dynamically calculating totals on "page load" will incur some performance loss. At this stage the number of images is approx. 100.
Umbraco experts - I would appreciate your views on the best way to achieve this?
For future refernce / anyone stumbling across this post I have figured out a solution to the above.
100% credit goes to the Douglas Robar and his fantastic XSLT Search package. I recalled seing some of his code detail the sorting of search results so used this logic to sort the nodes based on 3 separate fields.
The solution I have implemented uses some inline c# code to perform the sum calculations.
I hope this is clear enough - feel free to get in touch if you find this and want to discuss. I feel like I am able to finally give something back to the Umbraco community.
Suming and sorting of nodes
Hey
Just looking for direction / advice:
I am creating a photo website that runs online competitions. There is to be voting for the competitions that I intend storing within fields on the node. So the pseudo data structure will look like:
Initially I was intending to add another field (totalScore) and have an event handler to loop through and perform the calculation and store the total. The resulting XSLT output could then be easily sorted by the totalScore field.
But then I thought there might be a way of dynamically calculating the totals instead, but in doing so it seems that the sorting part is somewhat harder.
I prefer the latter solution as it keeps things more simple - it also reduces the potential for bugs in my code and an XSLT is easier to fix than compiled code. :-)
However I guess dynamically calculating totals on "page load" will incur some performance loss. At this stage the number of images is approx. 100.
Umbraco experts - I would appreciate your views on the best way to achieve this?
With regards
Nigel
For future refernce / anyone stumbling across this post I have figured out a solution to the above.
100% credit goes to the Douglas Robar and his fantastic XSLT Search package. I recalled seing some of his code detail the sorting of search results so used this logic to sort the nodes based on 3 separate fields.
The solution I have implemented uses some inline c# code to perform the sum calculations.
My code is as follows:
The c# code that goes just inside the closing </xsl:stylesheet> tag
Also in the opening <xsl:stylehseet> tag I added the following
and in the exclusions I added the "yy" bit !
I hope this is clear enough - feel free to get in touch if you find this and want to discuss. I feel like I am able to finally give something back to the Umbraco community.
is working on a reply...