place div after 1st child before 2nd child of a for-each
Hi
I have 8 divs that display an image, title and info in each from what the user has inputted using doc type properties. I have xslt to show them when a new page is added under a certain sector.
I want to add a 9th div that goes inbetween the first and second divs from above with a logo in so it would looks as follows:
1 | logo | 2
3 | 4 | 5
6 | 7 | 8
on the page, right now i have used parameters to count the 2nd item and add the div with logo in but it is replacing the 2nd item rather than placing between 1 and 2 so right now it's doing this:
1 | 2 | 3
4 | 5 | 6
7 | 8 |
its counting the 2nd as the new logo div which i know about its just i'm not sure how to get it to insert the logo div after the 1st and before the 2nd. Here is a snippet of what i have so far :
place div after 1st child before 2nd child of a for-each
Hi
I have 8 divs that display an image, title and info in each from what the user has inputted using doc type properties. I have xslt to show them when a new page is added under a certain sector.
I want to add a 9th div that goes inbetween the first and second divs from above with a logo in so it would looks as follows:
1 | logo | 2
3 | 4 | 5
6 | 7 | 8
on the page, right now i have used parameters to count the 2nd item and add the div with logo in but it is replacing the 2nd item rather than placing between 1 and 2 so right now it's doing this:
1 | 2 | 3
4 | 5 | 6
7 | 8 |
its counting the 2nd as the new logo div which i know about its just i'm not sure how to get it to insert the logo div after the 1st and before the 2nd. Here is a snippet of what i have so far :
<xsl:template match="/">
<xsl:for-each select="$currentPage/squareLanding">
<xsl:if test="position() <= 9">
<xsl:apply-templates select=".">
<xsl:with-param name="index" select="position()" />
</xsl:apply-templates>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="squareLanding">
<xsl:param name="index" />
<div class="view view-tenth">
<xsl:if test="$index = 2">
<div class="logoSquare">
<img src="/images/trans.gif" />
</div>
</xsl:if>
<img>...
Any guide would be great! Thanks
Hi Molly,
Something like this should do it:
/Chriztian
Thank you Chriztian that's how i need it, it puts it as a 3rd position and not 2nd so it looks like this:
1 | 2 | logo
3 | 4 | 5
6 | 7 | 8
if i change test="position() = 2">
to
test="position() = 1"
or
test="position() = 3"
It displays as follows :
1 | logo
2 | 3 | 4
5 | 6 | 7
8
Thank you for getting back so quick :) :)
Hi again,
My mistake - should have been added *before* the normal output of course :-)
Changing to test for position() = 1 would be the easiest fix, though...
But are you saying that using either of 1 and 3 gives the same (wrong) output?
I'm assuming you have some CSS styling doing the column stuff...
/Chriztian
My bad Chriztian! I stupidly forgot to put a width back on the div and float it left! everything works perfects with position()=1
Thank you very much! Looking at the code is much more simpler than the way i was going with it which is always good!
is working on a reply...