Copied to clipboard

Flag this post as spam?

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


  • Bas Wensveen 54 posts 75 karma points
    Dec 29, 2010 @ 21:03
    Bas Wensveen
    0

    Selecting data in a node

    Hi,

     

    The xslt code generates a link element with an image for all nodes under $source. The src of the image is empty while the data in the node is available.

    Selecting the foto1 url fails, and I don't know why.

     

    Kind regards,

     

    Bas Wensveen

     

     

                        <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
                            <a href="{umbraco.library:NiceUrl(@id)}">                          
                                <xsl:element name="img">
                                    <xsl:attribute name="src">
                                        <xsl:value-of select="umbraco.library:GetXmlNodeById(@id)/data [@alias='foto1']"/>
                                    </xsl:attribute>
                                    <xsl:attribute name="alt">
                                        <xsl:value-of select="@nodeName" />
                                    </xsl:attribute>
                                </xsl:element>
                            </a>
                        </xsl:for-each>

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Dec 29, 2010 @ 21:10
    Tom Fulton
    1

    Hi Bas,

    First of all, are you on Umbraco 4.5+ ?  If so you'll want to change how you are calling 'foto1' for the new schema

     <xsl:value-of select="umbraco.library:GetXmlNodeById(@id)/data [@alias='foto1']"/>

    to

     

     <xsl:value-of select="umbraco.library:GetXmlNodeById(@id)/foto1"/>

    Actually it should really be changed to the below - since the property is on the current node in the loop you don't need to use the GetXmlNodeById function

     <xsl:value-of select="foto1"/>

     

    Secondly, what type of field is foto1?

    I'm assuming it's an upload field or media picker.  If it's an upload field then the above code should work as it should contain the path to the image.

     <xsl:value-of select="foto1"/>

    If it's a media field, you'll need to get the path using the GetMedia function, something like this:

    <xsl:if test="string(foto1) != ''">
    <xsl:value-of select="umbraco.library:GetMedia(foto1,false())/umbracoFile"/>
    </xsl:if>

    Let us know if this works..

    Thanks,
    Tom

  • Kim Andersen 1447 posts 2197 karma points MVP
    Dec 29, 2010 @ 21:11
    Kim Andersen
    1

    Hi Bas

    I assume that the foto1 property contains a direct path to an image. And as far as I can see you are using the new XML schema.

    If that's all correct you kan probably just change this line:

    <xsl:value-of select="umbraco.library:GetXmlNodeById(@id)/data [@alias='foto1']"/>

    to this:

    <xsl:value-of select="./foto1"/>

    /Kim A

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 29, 2010 @ 21:12
    Jan Skovgaard
    0

    Hi Bas

    Have you placed the image to be shown directly on a node using the upload property? Or do you select it from the media section using a media picker?

    If you select the image using a media picker you should use the umbraco.library:GetMedia extension instead, which is documented here: http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia (Make sure to look at the examples for umbraco 4.5.x)

     

    If you're uploading the image directly to the node you should just make <xsl:value-of select="yourimagepropertyname" />

    Hope this helps

    /Jan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 29, 2010 @ 21:12
    Jan Skovgaard
    0

    Damn...way to slow. You rock guys :-)

    /Jan

  • Bas Wensveen 54 posts 75 karma points
    Dec 30, 2010 @ 09:12
    Bas Wensveen
    0

    Hi Tom,

     

    Yes I use Umbraco 4.5+. I did not realize that the xml scheme changed so dramatically. Could you point me to a list of changes between new xml schema  and the one before?

     

    You solution solved the issue, thanks!

     

    Kind regards,

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 30, 2010 @ 09:33
    Jan Skovgaard
    2

    Hi Bas

    I think you could have a look at the umbraco.config in the app_data folder to get an idea about how the new schema looks. Instead of saving all as attributes in a data element they're are now saved as elements with the name of your property. That's really the main difference.

    If you have a site running v4.0.x and you need to upgrade it you don't need to change the XSLT files though since you can use the legacy schema by changing the <UseLegacyXmlSchema> from false to true in the umbracoSettings.config in the config folder.

    /Jan

  • Kim Andersen 1447 posts 2197 karma points MVP
    Dec 30, 2010 @ 13:03
    Kim Andersen
    1

    Hi Bas

    In this wiki you there's a comparison between the old and the new XML schema. It's gives you a nice overview of how the schema has changed.

    /Kim A

  • Bas Wensveen 54 posts 75 karma points
    Dec 31, 2010 @ 10:48
    Bas Wensveen
    0

     

    Thanks guys,

     

    I will look into the information you gave me.

     

    Happy new year!

     

    Regards,

     

Please Sign in or register to post replies

Write your reply to:

Draft