Copied to clipboard

Flag this post as spam?

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


  • Bruno Alexandre 29 posts 38 karma points
    Jul 09, 2011 @ 16:53
    Bruno Alexandre
    0

    Get properties Values

    I bought access to Umbraco.TV in order to create a new page in a existing Umbraco site (4.5.1)

    I want to be able to get in a page all information from all child nodes and I add a macro as:

    <xsl:template match="/">
      
      var refList = [
        <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
             {
                name: '<xsl:value-of select="@nodeName"/>', 
                logo: '<xsl:value-of select="data[@alias='logoImage']"/>',
                img:  '<xsl:value-of select="data[@alias='bigImage']"/>',
                html: '<xsl:value-of select="data[@alias='htmlContent']"/>'
             },</xsl:for-each>
      ];
      
    </xsl:template>

     

    So i'm looping through all child nodes and getting not only the name but the 3 properties I have for that Document Type:

    http://www.balexandre.com/temp/2011-07-09_1652.png

     

    But I'm getting all properties empty... what am I doing wrong?

     

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Jul 09, 2011 @ 17:07
    Chriztian Steinmeier
    0

    Hi Bruno,

    The syntax you've found uses the old legacy XML schema - the new one (since 4.6) makes it much easier:

    <xsl:template match="/">
    
      var refList = [
        <xsl:for-each select="$currentPage/*[@isDoc][not(umbracoNaviHide = 1)]">
             {
                name: '<xsl:value-of select="@nodeName" />', 
                logo: '<xsl:value-of select="logoImage]" />',
                img:  '<xsl:value-of select="bigImage]" />',
                html: '<xsl:value-of select="htmlContent]" />'
             },</xsl:for-each>
      ];
    
    </xsl:template>

    The built-in Umbraco properties (Id, nodeName etc.) are attributes as before, but custom properties are just named with the alias - so no more data[@alias = 'foo'] ...

    /Chriztian

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Jul 09, 2011 @ 17:09
    Chriztian Steinmeier
    0

    PS: To get the Rich Text editor content as HTML output, use the disable-output-escaping flag:

    <xsl:value-of select="htmlContent" disable-output-escaping="yes" />

    /Chriztian

  • Bruno Alexandre 29 posts 38 karma points
    Jul 09, 2011 @ 17:11
    Bruno Alexandre
    0

    Got it, I can just use

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

    :o)

     

    P.S. I answered without seeing that I had 2 questions already... I think I'm to used to StackOverflow UI :(

     

     

  • Bruno Alexandre 29 posts 38 karma points
    Jul 09, 2011 @ 17:19
    Bruno Alexandre
    0

    Chriztian thank you for the disable output escaping part!

    btw, the ImagePicker gives me a string Id, how can i convert it to the full path?

    <xsl:value-of select="umbraco.library:NiceUrlFullPath(logoImage)"/>

    code above complains about 

    System.OverflowException: Value was either too large or too small for an Int32.

     

    and just as string(variable), I tried with

    <xsl:value-of select="umbraco.library:NiceUrlFullPath(int(logoImage))"/>

    and it complains again :(

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Jul 09, 2011 @ 17:27
    Chriztian Steinmeier
    0

    Hi Bruno,

    Images are special - you need to call umbraco.library:GetImage(ID_HERE, false()) to get a chunk of XML from where you can grab width, height, extension etc.

    Read Lee Kelleher's blogpost about it here: http://blog.leekelleher.com/2010/08/11/how-to-use-umbraco-library-getmedia-in-xslt-for-umbraco-v4-5/

    /Chriztian

  • Bruno Alexandre 29 posts 38 karma points
    Jul 09, 2011 @ 17:48
    Bruno Alexandre
    0

    Many thanks for the help.

    I ended up using:


      var refList = [
        <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
          <xsl:variable name="varLogoImage" select="logoImage"/>
          <xsl:variable name="varBigImage" select="bigImage"/>
          
             {
                name:        '<xsl:value-of select="@nodeName"/>', 
                logo_id:     '<xsl:value-of select="$varLogoImage" />',
                logo_path:   '<xsl:if test="string($varLogoImage) != ''">
                                <xsl:value-of select="umbraco.library:GetMedia($varLogoImage, 0)/umbracoFile" />
                              </xsl:if>',
                imp_id:      '<xsl:value-of select="$varBigImage" />',
                img_path:    '<xsl:if test="string($varBigImage) != ''">
                                <xsl:value-of select="umbraco.library:GetMedia($varBigImage, 0)/umbracoFile" />
                              </xsl:if>',
                description: '<xsl:value-of select="htmlContent" disable-output-escaping="yes"/>'
             },</xsl:for-each>
      ];

     

    and the output is something like:


    var refList = [
    
             {
                name:        'BIG', 
                logo_id:     '1293',
                logo_path:   '/media/26061/big.jpg',
                imp_id:      '1291',
                img_path:    '/media/26055/ref-big.jpg',
                description: '

    Company Big

    '
             },
             {
                name:        'Zyxel', 
                logo_id:     '1294',
                logo_path:   '/media/26064/zyxel.jpg',
                imp_id:      '1300',
                img_path:    '/media/26082/ref-zyxel.jpg',
                description: '

    Company Zyxel

    '
             },
             {
                name:        'Dansk Ædelmetal', 
                logo_id:     '1296',
                logo_path:   '/media/26070/dk_aedelmetal.jpg',
                imp_id:      '1298',
                img_path:    '/media/26076/ref-dansk-aedelmetal.jpg',
                description: '

    Company DK_Aedelmetal

    '
             },
      ]
    
  • 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