Im trying to format a for-each loop so that the results appear in a two column page.
the way i thought of doing this wiould be a loop count however research into xslt loops show its not the correct style (being functional over procedural). Any ideas how to go about this?
heres the code i am currently using (including my failed procedural loop count)
The trouble with xsl:variables is that you can't re-assign a value to it (they are variables in a sense that their data-type can be string, number, node-set, etc).
Loops in XSLT have a natural counter in form of the "position()" function.
Here's an example of how you could put your "photo thumbnails" into 2 columns.
[code][/code]
The first "if" checks if the position() is an odd number, then displays an opening "div" tag.
The last "if" then checks if the position() is an even number, and closes the "div" tag.
This example isn't fool-proof, as if your node-set has an odd number of items, there will be a "div" left open.
Thanks Lee! It seems to work perfectly (for the time being, still need to test it fully) but im sure i can modifiy what youve provided to meet what i need.
XSLT fomatting
Hi All.
Im trying to format a for-each loop so that the results appear in a two column page.
the way i thought of doing this wiould be a loop count however research into xslt loops show its not the correct style (being functional over procedural). Any ideas how to go about this?
heres the code i am currently using (including my failed procedural loop count)
[code]
]>
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"
exclude-result-prefixes="msxml umbraco.library">
[$counter]
[/code]
Thanks in advance
Hi Arekku,
The trouble with xsl:variables is that you can't re-assign a value to it (they are variables in a sense that their data-type can be string, number, node-set, etc).
Loops in XSLT have a natural counter in form of the "position()" function.
Here's an example of how you could put your "photo thumbnails" into 2 columns.
[code][/code]
The first "if" checks if the position() is an odd number, then displays an opening "div" tag.
The last "if" then checks if the position() is an even number, and closes the "div" tag.
This example isn't fool-proof, as if your node-set has an odd number of items, there will be a "div" left open.
Good luck!
Cheers,
- Lee
Thanks Lee! It seems to work perfectly (for the time being, still need to test it fully) but im sure i can modifiy what youve provided to meet what i need.
Many thanks again
is working on a reply...