Copied to clipboard

Flag this post as spam?

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


  • syn-rg 282 posts 425 karma points
    Jan 07, 2013 @ 06:47
    syn-rg
    0

    Comma separated multiple textstrings list

    I'm creating a macro that sources a property from the current member. The property uses the "multiple textstrings" datatype, and each textstring contains a media ID, the version number and the date and time added.

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    
    <xsl:param name="currentPage"/>
    
    <xsl:template match="/">
    
        <xsl:if test="count(umbraco.library:GetCurrentMember()/assetDownloads/values/value) > 0">
            <ul>
                <xsl:for-each select="umbraco.library:GetCurrentMember()/assetDownloads/values/value">
                    <li>
                        <xsl:if test="./preview != ''">
                            <img>
                                <xsl:attribute name="src">
                                    <xsl:value-of select="./preview" />
                                </xsl:attribute>
                            </img>
                        </xsl:if>
                        <p><xsl:value-of select="current()"/></p> 
                    </li>
                </xsl:for-each>
            </ul>
        </xsl:if>
    
    </xsl:template>
    • 1475,1,28-Dec-12 01:26:45

    • 1475,1,28-Dec-12 01:27:03

    How can I seperate the string so I can display details from the media type? I'd like to display the preview image from media type and the nodeName of the media type.

    Can anybody assist me with this?

    Cheers, JV

  • Sebastian Dammark 581 posts 1385 karma points
    Jan 07, 2013 @ 08:02
    Sebastian Dammark
    0

    Hi JV

    Try this one: http://our.umbraco.org/wiki/reference/umbracolibrary/split

    or this small template.
    I havent tested this one yet :)

    <xsl:template match="text()" name="split">
    <xsl:param name="input" select="." />
        <xsl:if test="$input[normalize-space()]">
        <xsl:value-of select="substring-before(concat($input,','),',')"/>
            <xsl:call-template name="split">
                <xsl:with-param name="input" select="substring-after($input, ',')"/>
            </xsl:call-template>
        </xsl:if>
    </xsl:template> 
  • syn-rg 282 posts 425 karma points
    Jan 08, 2013 @ 00:12
    syn-rg
    100

    Thanks Sebastian,

    I've used the following solution:

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    
    <xsl:param name="currentPage"/>
    <xsl:variable name="contentSplit" select="umbraco.library:Split(current(), ',')" />
    
    <xsl:template match="/">
    
        <xsl:if test="count(umbraco.library:GetCurrentMember()/assetDownloads/values/value) > 0">
            <ul>
                <xsl:for-each select="umbraco.library:GetCurrentMember()/assetDownloads/values/value">
                    <li>
    
                        <!-- Split values via , comma using below function -->
                        <xsl:variable name="contentSplit" select="umbraco.library:Split(current(), ',')" />
    
                        <xsl:for-each select="$contentSplit/value">
    
                            <!-- First value as media type id -->
                            <xsl:if test="position() = 1">
                                <img>
                                    <xsl:attribute name="src">
                                        <xsl:value-of select="umbraco.library:GetMedia(., 0)/preview" />
                                    </xsl:attribute>
                                </img>
                                <p><xsl:value-of select="umbraco.library:GetMedia(., 0)/@nodeName" /></p>
                            </xsl:if>
    
                            <!-- Second value as version number -->
                            <xsl:if test="position() = 2">
                                <p>
                                    Version: <xsl:value-of select="." />
                                </p>
                            </xsl:if>
    
                            <!-- Third value as date and time of download -->
                            <xsl:if test="position() = 3">
                                <p>
                                    Date Time: <xsl:value-of select="." />
                                </p>
                            </xsl:if>
    
                        </xsl:for-each>
    
                    </li>
                </xsl:for-each>
            </ul>
        </xsl:if>
    
    </xsl:template>
Please Sign in or register to post replies

Write your reply to:

Draft