Copied to clipboard

Flag this post as spam?

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


  • mfeola 117 posts 221 karma points
    Jun 22, 2011 @ 19:32
    mfeola
    0

    Quick XSLT example?

    I know you have on the main page that you will include an XSLT when you have your home site set up but i dont see a way of getting that content now?  i tried a few XSLTs and just displaying the field itself and so far no luck.  can you post a short XSLT example of how to pull out the content?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 22, 2011 @ 19:39
    Tom Fulton
    2

    Hi,

    I haven't used this package yet so I'm not sure of it's XML schema, but if you do a dump of the XML we should be able to figure it out.  Try adding the below to your macro and paste the XML that appears in the textbox to find out how it's storing it's XML.

    <textarea><xsl:copy-of select="$currentPage/yourPropertyAliasHere" /></textarea>

    -Tom

  • aghy 129 posts 308 karma points
    Jun 22, 2011 @ 19:44
    aghy
    2

    Hi mfeola,

    Yeh I still need to build my own site to host all my code and examples and documentation. Anyway until then to access your MultiType items you can use this code:

    <xsl:for-each select="$currentPage/labelsAndValues/Items">
      <xsl:value-of select="./Item"/>
    </xsl:for-each>

    I have a document type with a property with an alias of labelsAndValues and type of MultiType.

    Then if you need to access your Item properties then you can use the alias you defined on the MultiType datatype:

    <xsl:for-each select="$currentPage/labelsAndValues/Items">
      Label: <xsl:value-of select="./Item/label"/>
      Value: <xsl:value-of select="./Item/value"/>
    </xsl:for-each>

    Hope this helps
    Ben

  • mfeola 117 posts 221 karma points
    Jun 22, 2011 @ 19:45
    mfeola
    0

    oh, great idea! now all the XML is coming up.  

    im sure i can figure it out now that i see the schema of it but here is what i have

    <featuredItem2>
    <Items>
    <Item id="1" sortId="1">
    <title>Featured Item 2</title>
    <caption>Testing to see how to display it</caption>
    <description>hope it works</description>
    <image>1212</image>
    </Item>
    </Items>
    </featuredItem2>
  • aghy 129 posts 308 karma points
    Jun 22, 2011 @ 19:53
    aghy
    0

    Oh yeh and as you can see if you use an media picker it will save the node id of the image therefore I usually use:

    <xsl:variable name="image" select="umbraco.library:GetMedia($imageId, 'true')/umbracoFile"/>

    To get the image the I can use $image which will look something like /media/72/image.jpg

    <xsl:value-of select="$image"/>

    Ben

     

Please Sign in or register to post replies

Write your reply to:

Draft