Copied to clipboard

Flag this post as spam?

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


  • Fuji Kusaka 2203 posts 4220 karma points
    Dec 19, 2012 @ 10:46
    Fuji Kusaka
    0

    Getting the First value of Multiple TextString

    Hi everyone,

    Can someone tell me how to display the first value  of a multiple textString where the property alias is associated to the mediaType image.

    Am using the built  in multiple TextString from v4.9.1

    Here is how my code looks like

    <xsl:when test="$currentPage/ancestor-or-self::*[@id=1050]">
              <xsl:for-each select="umbraco.library:GetMedia($gallery, 1)/Image">
                <xsl:choose>
                  <xsl:when test="position() =1">
                    <xsl:element name="a">
                      <xsl:attribute name="href">
                        <xsl:value-of select="umbraco.library:GetMedia(@id, 0)/umbracoFile"/>
                      </xsl:attribute>
                      <xsl:attribute name="rel">prettyPhoto[<xsl:value-of select="../@nodeName"/>]</xsl:attribute>
                      <xsl:attribute name="title">
                        <xsl:value-of select="$currentPage/test/values/value[1]"/>
                      </xsl:attribute>
                      <xsl:element name="span">
                        <xsl:attribute name="class">
                          <xsl:value-of select="string('page-buttons gallery')"/>
                        </xsl:attribute>
                        <xsl:value-of select="umbraco.library:GetDictionaryItem('Gallery')"/>
                      </xsl:element>
                    </xsl:element>
                  </xsl:when>

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Dec 19, 2012 @ 11:11
    Lee Kelleher
    0

    Hi Fuji,

    Just to clarify, is the Multiple Textstring data-type on the Content or Media node?

    Thanks, Lee.

  • Fuji Kusaka 2203 posts 4220 karma points
    Dec 19, 2012 @ 11:19
    Fuji Kusaka
    1

    Hi Lee,

    Got it working, my mistake, and yes using it in the Media Node itself.

    It should be 

    <xsl:value-of select="test/values/value[1]"/>

    Instead of 

    <xsl:value-of select="$currentPage/test/values/value[1]"/>
  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Dec 19, 2012 @ 11:20
    Lee Kelleher
    0

    I had that thought, but then wasn't sure where the property was... glad that you've got it sorted! :-)

    Cheers, Lee.

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Dec 19, 2012 @ 16:27
    Chriztian Steinmeier
    0

    Hi Fuji,

    The code you posted may have been taken out of a larger context, but in my ongoing quest for getting rid of XSLT that looks much worse than it is, here is a simpler way to do it:

    <xsl:when test="$currentPage/ancestor-or-self::*[@id = 1050]">
        <xsl:variable name="media" select="umbraco.library:GetMedia($gallery, 1)" />
        <!-- Process the first Image -->
        <xsl:apply-templates select="$media[not(error)]/Image[1]" />
    </xsl:when>
    
    ...
    
    <!-- Template for an Image -->
    <xsl:template match="Image">
        <a href="{umbracoFile}" rel="prettyPhoto[{../@nodeName}]" title="{test/values/value[1]}">
            <span class="page-buttons gallery">
                <xsl:value-of select="umbraco.library:GetDictionaryItem('Gallery')" />
            </span>
        </a>
    </xsl:template>
    
    Ask all you want about how it works, if you like :-)

    /Chriztian

  • Fuji Kusaka 2203 posts 4220 karma points
    Dec 20, 2012 @ 15:53
    Fuji Kusaka
    0

    Thanks for the input Chriztian, now i bumped into any issue where the client wasnt the possibility to change the folder name, so adding the MultipleTextString to the mediaType Folder property.

    Can you explain how do get the property  ?

    Did something like 

     <xsl:variable name="mediaItems" select="umbraco.library:GetMedia($mediaFolder/*/@id, 'true')/Folder" />    
    <xsl:for-each select="$mediaItems">
    <xsl:value-of select="@nodeName"/>
     <xsl:value-of select="@Folder/altFolder/values/value[0]"/>
    </xsl:for-each>  

     

  • Fuji Kusaka 2203 posts 4220 karma points
    Dec 20, 2012 @ 15:54
    Fuji Kusaka
    0

    tryied something like but not working either

    <xsl:value-of select="altFolder/values/value[0]"/>
  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Dec 20, 2012 @ 16:04
    Chriztian Steinmeier
    0

    Hi Fuji,

    I don't quite follow, I'm afraid — did you move the Multiple Textstring property to the folder, and need to grab it from there while you're in the Image template (or context) ?

    Then you need to go up to the parent - someting like:

    <xsl:value-of select="../PROPERTYALIAS/values/value[1]" />

    /Chriztian

     

  • Fuji Kusaka 2203 posts 4220 karma points
    Dec 20, 2012 @ 16:14
    Fuji Kusaka
    0

    Hi Chrizitian,

    Yes we move it to the Folder Media Type tried your code but without luck 

      <xsl:variable name="mediaItems" select="umbraco.library:GetMedia($mediaFolder/*/@id, 'true')/Folder" />    
     <div class="photoGal-container">
    <xsl:for-each select="$mediaItems">
     <div class="photoGal">
    <xsl:value-of select="@nodeName"/>
     <xsl:value-of select="../altFolder/values/value[0]"/>
    </div>
    </xsl:for-each>
    </div>
Please Sign in or register to post replies

Write your reply to:

Draft