Creating a "grid view".
This is an open discussion with 9 replies, filed under General.
Search
I'm not stalking :)
Try this: http://getsymphony.com/discuss/thread/37303/, The Modulo approach can be used to count entries and allow presentation based on the number of entries in a line... I needed it to be able to split a series of video entries over 2 columns equally on this site... http://rhyfeddod.co.uk pardon the slow load! clients host.
EDIT This is obviously one approach, there are many ways to skin a cat! applying a class to the last item in a row using modulo would allow you to create a CSS rule that drops the item down onto the next row of items for example.
I'm nothing but glad for fast replies :)
Yes, there are multiple ways of doing this client side... but i need to do some modification to every 4th or so entry, even it it's just adding a class to remove margin-right if they for example are floating inside a container.
Will check your link!
A few others:
If you just need to do something every nth, you can call the position()
function:
<xsl:for-each select="entry"> <xsl:if select="position() mod 4 = 0"> every 4th! </xsl:if> </xsl:for-each>
Hmm either i'm not getting it or whats described in the link is not really what i'm asking for.
For example, say that i have 10 entries, and i want to output the following
Edit: gonna put some example code on xpathr or something, brb
Edit 2: http://xpathr.com/view/1877920/6a088b7fe1c1ff00c1b9b7b09b842eb0fa0174fb/
Thanks, that last post was what i was looking for @nickdunn.
I got it working..
http://xpathr.com/view/1877920/ce021a3328662d6d7cf45005b04969b434a341e3/
But - next question.. is there any way i can get around printing out the full markup twice and just add the extra class?
In PHP i'd do something like run a shorthand IF inside the tag or assign $class = " class='last'"; and output $class inside the div tag.
Gets kind of tricky when you need to close all tags properly though ;)
Edit: Maybe call for a template for the stuff that should be inside the div-tag inside each variation of it?
Edit 2: Yep, that was it :) ?
It's a bit trickier if you want, let's say, add a class to every first item of the row:
@iwyg kool! saving for later :)
Create an account or sign in to comment.
Hi,
I guess this is a problem everyone will have sometime during their first Symphony projects, but i don't know what to search for. Sorry if im duplicating..
Say you have a data source of items and want do display them in a grid on multiple lines.
In PHP you'd probably create a $counter variable and if it reaches a certain value you would inject "
My problem is to accomplish this in Xslt.