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.
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
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)"
/>
That code needs to go inside your foreach loop.
Rich
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>
is working on a reply...