Copied to clipboard

Flag this post as spam?

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


  • davelane 29 posts 73 karma points
    Oct 18, 2011 @ 14:59
    davelane
    0

    Only seeing relationship in one direction despite bidirectional relationship

    Hi everyone,

    I'm trying to use relationships to relate translated pages, but for some reason the (bidriectional) relationship is only showing up on one language. I'm using the standard xslt:

    <xsl:variable name="relations" select="umbraco.library:GetRelatedNodesAsXml($currentPage/@id)//relation [@parentId = $currentPage/@id]"/>
    <ul>
    <xsl:for-each select="$relations">
            <xsl:variable name="url" select="umbraco.library:NiceUrl(@childId)" />
            
            <xsl:if test="$url != ''">
            <li><href="{$url}"><xsl:value-of select="./node/@nodeName" /></a></li>
            </xsl:if>
    </xsl:for-each>
    </ul>

    I've verified that the relationship is indeed dual, and I'm just completely stumped.

    Thanks for any help!
    Dave

  • davelane 29 posts 73 karma points
    Oct 18, 2011 @ 18:12
    davelane
    0

     

    I figured it out

    First off, I posted inaccurate code above. I should have removed

    [@parentId = $currentPage/@id]

    from the first line.

    Second, I was only checking to see what the child relation was, where I should have been also comparing the parent. So I used an if statement to see which one I was dealing with:

    <xsl:variable name="url">
    <xsl:choose>
    <xsl:when test="@childId = $currentPage/@id">
    <xsl:value-of select="umbraco.library:NiceUrl(@parentId)" />
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="umbraco.library:NiceUrl(@childId)" />
    </xsl:otherwise>
    </xsl:choose>
    </xsl:variable>

     

Please Sign in or register to post replies

Write your reply to:

Draft