Copied to clipboard

Flag this post as spam?

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


  • Matias 27 posts 68 karma points
    Feb 27, 2013 @ 18:07
    Matias
    0

    Getting property value from media item and inserting them

    Hallo everyone

    I need some help getting some textfield info into my XSLT, it sounds quite easy, but I can't figure out how to do it. My kode looks like this:

    <xsl:template match="/">
        <xsl:variable name="mediaId"     select="number($currentPage/topSliderImage)" />
    
        <xsl:if test="$mediaId > 0">
            <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
    
            <xsl:for-each select="umbraco.library:GetMedia($mediaId, '1')/SliderImage">           
                <xsl:variable name="title" select="sliderImagetitle" />
                <xsl:variable name="BGColor" select="sliderImageBackgroundColor" />
                <xsl:variable name="link" select="sliderImagelink" />
                <xsl:variable name="textColor" select="sliderimagetekstcolor" />
    
            <xsl:if test="$title = ''">
                <li style="background-color:$BGColor">
    <div> <img> <xsl:attribute name="src"> <xsl:value-of select="sliderimageupload" /> </xsl:attribute> </img> </div> </li> </xsl:if> <xsl:if test="$title != ''"> <li style="background-color:# $BGColor"> <div class="headline_content"> <div class="hd_content_left"> <font color="#$textColor"> <h1> <xsl:value-of select="sliderImagetitle" /> </h1> <p> <xsl:value-of select="sliderimagetekst" /> </p> </font> <br /> <a href=" $link">Read more</a> </div> <div class="hd_content_right"> <img> <xsl:attribute name="src"> <xsl:value-of select="sliderimageupload" /> </xsl:attribute> </img> </div> </div> </li> </xsl:if> </xsl:for-each> </xsl:if> </xsl:template>

    I have bolded the places where the problem is.

    I know that the title is working, as it goes into the different if statements. However the both the link, BGColor and textColor is not working. Any ideas why?

  • Rich Green 2246 posts 4008 karma points
    Feb 27, 2013 @ 18:13
    Rich Green
    0

    You need xsl:attribute

    <xsl:attribute name="style">background-color:<xsl:value-ofselect="$BGColor"/></xsl:attribute>

    Rich

  • Matias 27 posts 68 karma points
    Feb 27, 2013 @ 18:33
    Matias
    0

    I substitude:

    <li style="background-color:# $BGColor">

    With:

    <li <xsl:attribute name="style">background-color:<xsl:value-ofselect="$BGColor"/></xsl:attribute>>

    Correct?

    Got the error message:

     Et navn kan ikke begynde med tegnet '<', hexadecimal værdi 0x3C.

    Translated: A name can't begin with the sign '<', hex value 0x3C

  • Rich Green 2246 posts 4008 karma points
    Feb 27, 2013 @ 18:41
    Rich Green
    0

    try

    <xsl:attributename="style">background-color:<xsl:value-of select="$BGColor"/></xsl:attribute>
  • Rich Green 2246 posts 4008 karma points
    Feb 27, 2013 @ 18:41
    Rich Green
    0

    damn editor....

    <xsl:attribute name="style">background-color:<xsl:value-ofselect="$BGColor"/></xsl:attribute>

     

  • Rich Green 2246 posts 4008 karma points
    Feb 27, 2013 @ 18:42
    Rich Green
    0

    I give up with the editor, but it needs to be "value-of select" (see the space)

    Rich

  • Rich Green 2246 posts 4008 karma points
    Feb 27, 2013 @ 18:49
    Rich Green
    0

    New post so you get a notification.

    However, I reread your post, don't put the style there, it works like this:

     

    <li>
    <xsl:attributename="style">
    background-color:<xsl:value-ofselect="$BGColor"/>
    </xsl:attribute>
    </li>

     

     

  • Matias 27 posts 68 karma points
    Feb 27, 2013 @ 18:49
    Matias
    0

    Did not see my own mistake in the editor too, but it is with a space (If there was only missing 1).

  • Matias 27 posts 68 karma points
    Feb 27, 2013 @ 19:10
    Matias
    0

    Thanks a lot! It is now working!

    I have notice that all this is coming in the html source code, what is that?

    &#xA;&#x9;&#x9;&#x9;&#x9;&#x9

    Another problem with the font part, because that need a closing tag at the end. How do I do that?

    I though I could do like this:

    <h1>
    <xsl:attribute name="font">
    #<xsl:value-of select="$textColor"/>
    <xsl:value-of select="sliderImagetitle" />  
    </xsl:attribute>
     
    </h1>
  • Rich Green 2246 posts 4008 karma points
    Feb 27, 2013 @ 19:15
    Rich Green
    0

    To get rid of the nasty source code, just remove all the spaces you don't need, so...

    <h1><xsl:attribute name="font">#<xsl:value-of select="sliderImageTitle:/></xsl:attribute></h1>

    Rich

  • Matias 27 posts 68 karma points
    Feb 27, 2013 @ 19:21
    Matias
    0

    Sorry I was not clear enough.

    The nasty source code was for the style background color.

    The part of the font was a problem, cause the $textColor is the color of the text located inside sliderImagetitle. So how do I do that work around so the tekst in going to be inside the <font> / </font>?

  • Rich Green 2246 posts 4008 karma points
    Feb 27, 2013 @ 19:26
    Rich Green
    0

    Font is not an attribute, so just use:

    <font><xsl:value-of select="sliderImageTitle"/></font>

    If I have not understood correctly, please post the HTML mark up you are trying to achieve.

    Rich

  • Matias 27 posts 68 karma points
    Feb 27, 2013 @ 19:58
    Matias
    0

    You are totally right, the font was not the attritube, the color was. It is working perfectly! Thanks again. Any think I should do in order for you to get some kind of credit (if this system works with credit).

    Now my last problem seems to be the link, I added a "relative links" in my media type, and though I could use that one to give links around. But it does not seem to send any data. Is there a better way to this, so it is still easy for the user to use?

  • Rich Green 2246 posts 4008 karma points
    Feb 27, 2013 @ 20:48
    Rich Green
    0

    Hey Matias,

    I would open up a new post if you have a new question.

    Rich

Please Sign in or register to post replies

Write your reply to:

Draft