Copied to clipboard

Flag this post as spam?

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


  • Ulla Skaanning 67 posts 97 karma points
    Dec 17, 2011 @ 00:08
    Ulla Skaanning
    0

    insert link to child node with specific name

    Hi

    I have a structure thats somethins like this:

    homepage > subpage doctype "subpage" >child of subpage doctype "GalleryAlbum"

    Now I want to use XSLT to place a button in "subpage" which contains a link to the child node with doctype "GalleryAlbum", IF theres is a child node with doctype "GalleryAlbum" ELSE do nothing.

    I want to use XSLT beacuse I need the link to be dynamic, so that every page with the doctype "subpage" will show a link to its own specific "GalleryAlbum" child.

    I have tried all sorts of ways to do this, but nothing seems to work, so now I would really like to get some fresh eyes on the issue.

    I know it's propably simple, but I just can't get it right - hope you guys have some input :)

    //Cheers

    BTW: I'm using the new schema (4.7.0)

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Dec 17, 2011 @ 01:07
    Tom Fulton
    2

    Hi,

    It should be pretty simple, you can use something like this:

    <xsl:template match="/">
      <xsl:apply-templates select="$currentPage/GalleryAlbum [@isDoc][1]"/>  <!-- The [1] means to only grab the first one, in case you might have multiple GalleryAlbums? -->
    </xsl:template>

    <xsl:template match="GalleryAlbum">
      Link to Gallery:  <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>
    </xsl:template> 

    Hope this helps,
    Tom 

  • Ulla Skaanning 67 posts 97 karma points
    Dec 17, 2011 @ 12:51
    Ulla Skaanning
    0

    Hi Tom

    This works exactly as intended - I didn't think to do the selecet like that, but of course that works :)

    Thanks a mill :)

Please Sign in or register to post replies

Write your reply to:

Draft