Copied to clipboard

Flag this post as spam?

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


  • hlintrup 6 posts 22 karma points
    Oct 28, 2010 @ 21:38
    hlintrup
    0

    Get url of document type property

    I do a foreach on a document type in xslt and I need to get the url of a property on each "instance" of the visited document types.

    It like this: I have a document type called VideoItem which has a MediaPicker property 'video'. Each instance of VideoItem.video points to a media item. I need to get the url of that media item, but I just cant figure it out.

    Any help is greatly appreciated!

    Best Regards

    HKAL

  • Rich Green 2246 posts 4008 karma points
    Oct 28, 2010 @ 21:58
    Rich Green
    2

    Hi,

    Have a look at the sample code here http://blog.leekelleher.com/2010/08/11/how-to-use-umbraco-library-getmedia-in-xslt-for-umbraco-v4-5/ 

    You just need to change this line

     <xsl:variable name="mediaId" select="number($currentPage/mediaId)" />

    To something like this

     <xsl:variable name="mediaId" select="number(video)" />
  • Rich Green 2246 posts 4008 karma points
    Oct 28, 2010 @ 21:59
    Rich Green
    0

    That code needs to go inside your foreach loop.

    Rich

  • hlintrup 6 posts 22 karma points
    Oct 28, 2010 @ 23:12
    hlintrup
    0

    Rich, thank you so much. I worked like a charm. Below is the working xslt. This is certainly an outstanding forum!

     

    <xsl:variable name="documentTypeAlias" select="string('VideoItem')"/>

    <xsl:template match="/">

    <!-- start writing XSLT -->
      <xsl:for-each select="$currentPage/descendant::* [name() = $documentTypeAlias and string(umbracoNaviHide) != '1']">
        <xsl:variable name="mediaId" select="number(video)" />
        <xsl:if test="$mediaId > 0">
          <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
          <xsl:if test="$mediaNode/umbracoFile">
            <xsl:value-of select="$mediaNode/umbracoFile"/>
          </xsl:if>
        </xsl:if>    
      </xsl:for-each>
    </xsl:template>

Please Sign in or register to post replies

Write your reply to:

Draft