My site has 5 related product content pickers and i can see from the XML that they all have some data in it. I am trying to get the title of the related product so i can link to it. I can get the link to work using the NiceUrl library but when i try and get the title of the item it returns nothing?
I've never really used GetItem, but it looks like that should work. Does the target product have a field called "title" or are you actually trying to get the @nodeName ? Per this wiki it seems you cannot get the nodeName and other "attributes", only field data.
title is an field i have put as i saw you couldn't get to the @nodeName, i have read that wiki too but thought i was doing something wrong. The picked node does have a title field with something in it but i can inly assume that the GetItem function doesn't work?
<xsl:if test="$currentPage/relatedProduct1 > 0"> <!-- You might need this line to avoid errors when saving --> <xsl:variable name="targetPage" select="umbraco.library:GetXmlNodeById($currentPage/relatedProduct1)"/> <xsl:if test="not($targetPage/error)"> Title: <xsl:value-of select="$targetPage/title"/> </xsl:if> </xsl:if>
GetItem not returning anything
Hi,
My site has 5 related product content pickers and i can see from the XML that they all have some data in it. I am trying to get the title of the related product so i can link to it. I can get the link to work using the NiceUrl library but when i try and get the title of the item it returns nothing?
Can someone point me in the right direction or see if i've been a bit dumb?
Thanks
Chris
Hi Chris,
I've never really used GetItem, but it looks like that should work. Does the target product have a field called "title" or are you actually trying to get the @nodeName ? Per this wiki it seems you cannot get the nodeName and other "attributes", only field data.
-Tom
Hi Tom,
title is an field i have put as i saw you couldn't get to the @nodeName, i have read that wiki too but thought i was doing something wrong. The picked node does have a title field with something in it but i can inly assume that the GetItem function doesn't work?
Do you know a different way i could do it?
Thanks
Chris
Try this:
-Tom
Thanks Tom,
here's my final solution:
<xsl:if test="$currentPage/relatedProduct3 != '' and $currentPage/relatedProduct3 != $currentPage/@id"> <xsl:variable name="targetPage3" select="umbraco.library:GetXmlNodeById($currentPage/relatedProduct3)"/> <xsl:if test="not($targetPage3/error)"> <a href="{umbraco.library:NiceUrl($targetPage3/@id)}"> <xsl:choose> <xsl:when test="$targetPage3/title != ''"> <xsl:value-of select="$targetPage3/title" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="$targetPage3/@nodeName" /> </xsl:otherwise> </xsl:choose> </a> <br /> <hr /> </xsl:if> </xsl:if>Cool, glad it worked...not sure what's up with GetItem.
Also are you duplicating that code block for each picker? You could make one template to handle it all :)
-Tom
is working on a reply...
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.