Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 886 posts 2415 karma points
    Sep 20, 2012 @ 12:49
    Claushingebjerg
    0

    Splitting a list of media items

    I need to split a list of media items into humps of X

    <xsl:variable name="n" select="4"/>

    <xsl:template match="/">
      <ul>
        <xsl:apply-templates select="umbraco.library:GetMedia($currentPage/billedmappe, true())/Image [@isDoc][position() mod $n = 1]"/>
      
    </ul>
    </xsl:template>

    <xsl:template match="*[@isDoc]">
    <li>  
        <xsl:for-each select=". | following-sibling::*[@isDoc][position() &lt; $n]">
        <href="{umbraco.library:NiceUrl(@id)}">picname</a>   
        </xsl:for-each>
    </li>
    </xsl:template>

    What am i mising?

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Sep 20, 2012 @ 13:05
    Chriztian Steinmeier
    0

    Hi Claus,

    What do you get? - and what do you expect?

    It *looks* OK, but... I guess it depends a little

    /Chriztian

  • Claushingebjerg 886 posts 2415 karma points
    Sep 20, 2012 @ 13:19
    Claushingebjerg
    0

    i get an empty url..

    i expect to get:

    <ul>
    <li>
    <a href="/media/......">picname</a>
    <a href="/media/......">picname</a>
    <a href="/media/......">picname</a>
    <a href="/media/......">picname</a>
    </li>  <li>
    <a href="/media/......">picname</a>
    <a href="/media/......">picname</a>
    <a href="/media/......">picname</a>
    </li>
    </ul>

    If there are 7 images in the folder

  • Claushingebjerg 886 posts 2415 karma points
    Sep 20, 2012 @ 13:21
    Claushingebjerg
    0

    I meant i get an empty <ul></ul>

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Sep 20, 2012 @ 14:58
    Chriztian Steinmeier
    0

    Ah, OK.

    If I remember correct, media items don't have the @isDoc attribute - so remove that from the apply-templates and change the match attribute to Image instead:

    <xsl:apply-templates select="umbraco.library:GetMedia($currentPage/billedmappe, true())/Image[position() mod $n = 1]" />

    and:

    <xsl:template match="Image">
        <!-- ... -->
    </xsl:template>

    /Chriztian

  • Claushingebjerg 886 posts 2415 karma points
    Sep 21, 2012 @ 08:39
    Claushingebjerg
    0

    Of course :)

    Works perfectly.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies