Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Fredrik Esseen 610 posts 906 karma points
    Feb 24, 2010 @ 16:53
    Fredrik Esseen
    0

    Foreach and ul

    Hi!

    Im having a problem with creatin div inside an ul with li:s. There should be 6 divs inside one li and then a new li should be created. The problem it that the 13:th item is outside the li when looking in IE 7.

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:variable name="imagesPerRow" select="7"/>
    <xsl:variable name="imageFolder" select="number(1118)"/>
    <xsl:template match="/">
    <div id="slider">
    <ul width="940">    
    <xsl:variable name="liOpen"><xsl:text>&lt;li class="NewsItemLi"&gt;</xsl:text></xsl:variable> 
    <xsl:variable name="liClose"><xsl:text>&lt;/li&gt;</xsl:text></xsl:variable>
    <xsl:for-each select="$currentPage/ancestor-or-self::root//node[@nodeTypeAlias ='Banlista']/node[@nodeTypeAlias ='Hål']">
      <xsl:if test="position() = 1 or position() mod $imagesPerRow = 0"> 
               <xsl:value-of select="$liOpen" disable-output-escaping="yes" />
             </xsl:if>
      <div class="SliderItem">
      <xsl:variable name="picFile" select="data[@alias='imgAlias']"/>
      <xsl:if test="$picFile !=''">
       <div class="SliderImage">
       <xsl:variable name="galImage" select="umbraco.library:GetMedia($picFile,0)/data[@alias='umbracoFile']"/>
         <a href="{umbraco.library:NiceUrl(@id)}">
         <img>
          <xsl:attribute name="src">/umbraco/imageGen.aspx?image=<xsl:value-of select="$galImage"/>&amp;width=<xsl:value-of select="130"/>&amp;constrain=true</xsl:attribute>
          <xsl:attribute name="alt"><xsl:value-of select="./@nodeName" /></xsl:attribute>
          <xsl:attribute name="title"><xsl:value-of select="./@nodeName" /></xsl:attribute>
         </img>
         </a>
       </div>
      </xsl:if>
      <!--<div class="NewsHeader">
        <h2><xsl:value-of select="@nodeName"/></h2>
       </div>
       <div class="NewsText">
        <xsl:value-of select="$text" disable-output-escaping="yes"/>&nbsp;<a href="{umbraco.library:NiceUrl(@id)}">Läs mer</a>
       </div>-->
      </div>
     <xsl:if test="position() = ($imagesPerRow - 1) or position() mod ($imagesPerRow - 1) = 0 or position() = last()">
                <xsl:value-of select="$liClose" disable-output-escaping="yes"/>
             </xsl:if>
    </xsl:for-each>
    </ul>
    </div>

     Notice that I had to set the imagesPerRow to 7 and not 6 to make it work. Seems the problem is somewhere there...

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Feb 24, 2010 @ 17:59
    Douglas Robar
    0

    Looks like you're using the Runway Gallery as a starting point. I had a bad bit of logic in that that 'ruptures' the UL/LI flow in some instances.

    The solution is to update the two xsl:if statements, as Ricky pointed out on the forum some time ago...

    <!-- open a row of images -->
    <xsl:if test="position() mod $imagesPerRow = 1">
     
    <xsl:value-of select="$ulOpen" disable-output-escaping="yes" />
    </xsl:if>

    and

     <!-- close the row of images -->
    <xsl:if test="position() mod $imagesPerRow = 0 or position() = last()">
     
    <xsl:value-of select="$ulClose" disable-output-escaping="yes"/>
    </xsl:if>

    This also means that the $imagesPerRow variable can now be set the actual number of images you want.  So, change it to 6 instead of 7.

    cheers,
    doug.

  • Fredrik Esseen 610 posts 906 karma points
    Feb 26, 2010 @ 13:33
    Fredrik Esseen
    0

    Perfect!

    Thank you!

Please Sign in or register to post replies

Write your reply to:

Draft