This would create a tabel and by every second node there would be created a new row in the table. The value in the $mod variable is the number of nodes you want to run through before inserting a new table row, so it's pretty easy to change this in the future if you suddenly want to have three or four nodes on every row.
But actually depending on how the content should be shown on the website, I'd go for DIV's as well. But as I say, it depends. If the data you are showing are actually ment to be tabular, then I would go for table as well. But if you are building up the layout or something like that, I would go for the DIV's for sure. It's just more semantic correct :)
@Steinmeier: Yeah, I do know that Mr. XSLT :D Hadn't seen the other post, but it's actually a pretty simple and great example. It's bookmarked for later usage.
@Profiterole: Even though the code I provided works, I'd go for Chriztian's example in the other post the next time I need to do something similar.
table with for-each but two column
Hi, I try to do a table that would looks like that :
but for every childs node under a parent. I don't know how many nodes there's under the parent. I can do that :
but it will place every node in a row <tr>.
Can you help me?
Thank you
Hi Profiterole
You CAN do what you want with tables, e.g. by only selecting evey second in your for-each using something like this:
and then choose the next sibling also to show in your 2nd td.
However I often prefer to skip tables and use DIV's instead - in this case you can easily apply columns without knowing anything about the number.
Make sure 2 of your DIV's fit in width on your page, make them float left ... and then it's just adding your content in the DIV's.
>Tommy
Hi
You should be able to achieve this with this small piece of code:
This would create a tabel and by every second node there would be created a new row in the table. The value in the $mod variable is the number of nodes you want to run through before inserting a new table row, so it's pretty easy to change this in the future if you suddenly want to have three or four nodes on every row.
/Kim A
Hi, I tried Tommy's way, but I'm not a fan of DIVs. So I used Kim tips.
Great to hear that you can use the code!
But actually depending on how the content should be shown on the website, I'd go for DIV's as well. But as I say, it depends. If the data you are showing are actually ment to be tabular, then I would go for table as well. But if you are building up the layout or something like that, I would go for the DIV's for sure. It's just more semantic correct :)
/Kim A
Hi all,
I put a simple example of the clean XSLT approach Tommy describes, up here some time ago:
http://our.umbraco.org/forum/developers/xslt/11692-Simple-table-row-example-with-XSLT-templates
Kim's solution works great - it's just not (and he knows that) the cleanest cup of "XSLTea" you can get :-)
/Chriztian
@Steinmeier: Yeah, I do know that Mr. XSLT :D Hadn't seen the other post, but it's actually a pretty simple and great example. It's bookmarked for later usage.
@Profiterole: Even though the code I provided works, I'd go for Chriztian's example in the other post the next time I need to do something similar.
/Kim A
is working on a reply...