Ok so here is my issue. Currently using Umbraco 4.8.1 and trying to place the link to the attached Media file for a node in my navigation. This navigation menu dynamically calls all child nodes, however IF the child node with a DocType of "Media Redirect" I need to have the file path of the attached file used as the link and not the node ID.
Here are some of my basic values to use in the solution
DocType Alias = MediaRedirect
using a dataType = Media Picker Alias = mediaLink
So I have tried using a script like this:
<xsl:when test="mediaLink != ''"> <a href="{mediaLink}" target="_blank" style="padding-left:30px;"> <!-- output an extra class if there are children below this node --> <xsl:if test="$currentNode/*[@isDoc]"><xsl:attribute name="class">quadexpandable</xsl:attribute></xsl:if> <xsl:value-of select="@nodeName" /> </a> </xsl:when>
But that just gives me the Node ID.. and not the file path to the attached file... which is what I really want.. I've tried a lot of other solutions like this one:
<xsl:when test="mediaLink != ''"> <a href="{umbraco.library:GetMedia($currentPage/mediaLink,false)/umbracoFile}" target="_blank" style="padding-left:30px;"> <!-- output an extra class if there are children below this node --> <xsl:if test="$currentNode/*[@isDoc]"><xsl:attribute name="class">quadexpandable</xsl:attribute></xsl:if> <xsl:value-of select="@nodeName" /> </a> </xsl:when>
But have not been able to correctly create a herf URL link that is correct or that doesn't break the script. Can someone please help! Thank you in advance!
The second way is what you want, except it looks like you're pulling mediaLink from the currentPage instead of the current node in your loop. You should also check if its empty, otherwise you can get an error. Try something like this:
<xsl:when test="mediaLink != '' and mediaLink > 0"> <xsl:variable name="media" select="umbraco.library:GetMedia(mediaLink, false())" /> <xsl:if test="not($media/error)"> <!-- make sure the media still exists --> <a href="{$media/umbracoFile}" target="_blank" style="padding-left:30px;"> <!-- output an extra class if there are children below this node --> <xsl:if test="$currentNode/*[@isDoc]"><xsl:attribute name="class">quadexpandable</xsl:attribute></xsl:if> <xsl:value-of select="@nodeName" /> </a> </xsl:if> </xsl:when>
Retrieve Media Picker URL from file in XSLT
Ok so here is my issue. Currently using Umbraco 4.8.1 and trying to place the link to the attached Media file for a node in my navigation. This navigation menu dynamically calls all child nodes, however IF the child node with a DocType of "Media Redirect" I need to have the file path of the attached file used as the link and not the node ID.
Here are some of my basic values to use in the solution
DocType Alias = MediaRedirect
using a dataType = Media Picker
Alias = mediaLink
So I have tried using a script like this:
But that just gives me the Node ID.. and not the file path to the attached file... which is what I really want.. I've tried a lot of other solutions like this one:
But have not been able to correctly create a herf URL link that is correct or that doesn't break the script. Can someone please help! Thank you in advance!
Hi,
The second way is what you want, except it looks like you're pulling mediaLink from the currentPage instead of the current node in your loop. You should also check if its empty, otherwise you can get an error. Try something like this:
-Tom
THANKS TOM!
is working on a reply...