Copied to clipboard

Flag this post as spam?

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


  • Eddie Foreman 215 posts 288 karma points
    Sep 02, 2010 @ 17:32
    Eddie Foreman
    0

    Create link to child page

    Hi All

    I have the following scructure:

    Funds
    -Archive

    The archive page has a media picker, alias factSheetsArchive. From the funds page I would like to check if the a media folder has been selected on the archibe page.  If so then display a link to that page.

      <xsl:template match="/">
    <xsl:variable name="url" select="descendant::node [data[@alias = 'factSheetsArchive']]" />
    <xsl:if test="$url &gt; 0">
    <small>
    <a href="{umbraco.library:NiceUrl($url)}" class="new-window" title="Fund Archived Documents">Archived Documents</a>
    </small>
    </xsl:if>
    </xsl:template>


    I'm not getting any errors, but also no link?

    Umbraco 4.0.4.2

    Thanks

    Eddie

  • Claushingebjerg 939 posts 2574 karma points
    Sep 02, 2010 @ 20:35
    Claushingebjerg
    0

    <xsl:if test="$url != ''">

    instead of 

    <xsl:if test="$url &gt; 0">

  • Eddie Foreman 215 posts 288 karma points
    Sep 02, 2010 @ 22:12
    Eddie Foreman
    0

    Hi

    That was my thinking, but the link is not displayed?  

    Thanks

    Eddie

  • Eddie Foreman 215 posts 288 karma points
    Sep 02, 2010 @ 22:35
    Eddie Foreman
    0

    Hi

    Just tried this, which does produce a link.  Regardless of whether a folder has been selected?

      <xsl:template match="/">
    <xsl:for-each select="$currentPage/descendant::node ">
    <xsl:if test="./data [@alias = 'factSheetsArchive'] != ' '">
    <small>
    <a href="{umbraco.library:NiceUrl(@id)}" class="new-window" title="Fund Archived Documents">Archived Documents</a>
    </small>
    </xsl:if>
    </xsl:for-each>
    </xsl:template>

    Also tried and removed the currentPage

    <xsl:for-each select="$currentPage/descendant::node ">

    but this resulted in no link?

    Thanks

    Eddie

     

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Sep 03, 2010 @ 00:35
    Chriztian Steinmeier
    0

    Hi Eddie,

    The error in the first attempt is that your're saying "select the descendant node that has a factSheetArchive property" - so you're actually selecting the 'Archive' node instead of the property. You can do a couple of things to correct it:

    1. If the Archive node is a child of Funds, do this:

    <xsl:variable name="url" select="node[@nodeName = 'Archive']/data[@alias = 'factSheetsArchive']" />

    2. You could just add the property to the XPath to actually select it:

    <xsl:variable name="url" select="descendant::node[data[@alias = 'factSheetsArchive']/data[@alias = 'factSheetsArchive']" />

    /Chriztian

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Sep 03, 2010 @ 00:40
    Chriztian Steinmeier
    0

    Hi again,

    Just realized that that won't even work because you're inside the root template, so the context is wrong - you need to add $currentPage to the mix:

    xsl:variable name="url" select="$currentPage/node[@nodeName = 'Archive']/data[@alias = 'factSheetsArchive']" />

    /Chriztian

     

  • Eddie Foreman 215 posts 288 karma points
    Sep 03, 2010 @ 01:16
    Eddie Foreman
    0

    Hi /Chriztain

    Thanks for this, still no joy.

    The archive page has an id of 1275, so as a test I've updated the xslt to:

      <xsl:param name="currentPage"/>
    <xsl:template match="/">
    <xsl:variable name="url" select="node[@id = '1275']/data[@alias = 'factSheetsArchive']" />
    <xsl:if test="$url != ''">
    <small>
    <a href="{umbraco.library:NiceUrl($url)}" class="new-window" title="Fund Archived Documents">Archived Documents</a>
    </small>
    </xsl:if>
    </xsl:template>

    But again, still no link.

    Is the if test conditon correct?  If I remove this I get an error, from the following:

    {umbraco.library:NiceUrl($url)}

    Thanks

    Eddie

  • Eddie Foreman 215 posts 288 karma points
    Sep 03, 2010 @ 01:20
    Eddie Foreman
    0

    Sorry, just saw your last post, so added to the above test, but still the same?

      <xsl:variable name="url" select="$currentPage/node[@id = '1275']/data[@alias = 'factSheetsArchive']" />

     

     

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Sep 03, 2010 @ 09:20
    Chriztian Steinmeier
    0

    Hi Eddie,

    That'll only work when the current page is the parent of the page with id="1275" - you can use the GetXmlNodeById() function to grab that node, regardless of your current position:

    <xsl:variable name="url" select="umbraco.library:GetXmlNodeById(1275)/data[@alias = 'factSheetsArchive']" />

    /Chriztian 

Please Sign in or register to post replies

Write your reply to:

Draft