Copied to clipboard

Flag this post as spam?

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


  • Martin Vingaard 39 posts 60 karma points
    May 11, 2011 @ 11:31
    Martin Vingaard
    1

    Get parent name and url

    At the moment im trying to get the parent name and the link to the parent page.
    My current code is like this

    <xsl:variable name="parentPageUrl" select="umbraco.library:NiceUrl($currentPage/parent::node/@id)" />
        <href="{parentPageUrl}">
          <xsl:value-of select="$currentPage/parent::node/@nodeName" />
        </a>

    But sadly it dosnt work.
    Anyone got a solution.

    Thanks in advance

  • skiltz 501 posts 701 karma points
    May 11, 2011 @ 11:42
    skiltz
    0
    <xsl:variable name="parentPageUrl" select="umbraco.library:NiceUrl($currentPage/parent::*/@id)" /> 
       <a href="{parentPageUrl}">
          <xsl:value-of select="$currentPage/parent::*/@nodeName" />
       </a>
  • praveity 100 posts 125 karma points
    May 11, 2011 @ 11:58
    praveity
    0

    the parent node will be obviously the doc type so check only through the doc-type not all the properties

     

    <xsl:variable name="parentPageUrl" select="umbraco.library:NiceUrl($currentPage/parent::*[@isDoc]/@id)" /> 
       <a href="{$parentPageUrl}">
          <xsl:value-of select="$currentPage/parent::*[@isDoc]/@nodeName" /> 
       </a>
  • Martin Vingaard 39 posts 60 karma points
    May 11, 2011 @ 12:15
    Martin Vingaard
    0

    Thanks, the parent page is now listet but it links to the subpage im currently on, using

    <xsl:variable name="parentPageUrl" select="umbraco.library:NiceUrl($currentPage/parent::*/@id)" />

     while

     

     

    <xsl:variable name="parentPageUrl" select="umbraco.library:NiceUrl($currentPage/parent::*[@isDoc]/@id)" />

    gives me an error

     

    Maybe the error is elsewhere

    <xsl:output method="html" omit-xml-declaration="yes" />

    <xsl:param name="currentPage"/>


    <xsl:variable name="level" select="3"/>

    <xsl:template match="/">


    <ul>
      <li style="margin:0 0 5px 0;">
        <xsl:variable name="parentPageUrl" select="umbraco.library:NiceUrl($currentPage/parent::*[@isDoc]/@id)" />
      <xsl:variable name="parentPageUrl" select="umbraco.library:NiceUrl($currentPage/parent::*/@id)" /> 
       <href="{parentPageUrl}">
          <xsl:value-of select="$currentPage/parent::*/@nodeName" /> 
       a>
      li>
    <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
      <li style="margin:0 0 5px 0;">
        <href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        a>
      li>
    xsl:for-each>
    ul>

    xsl:template>

    xsl:stylesheet>


  • praveity 100 posts 125 karma points
    May 11, 2011 @ 12:23
    praveity
    1

    <xsl:output method="html" omit-xml-declaration="yes" />

    <xsl:param name="currentPage"/>

    <!-- Input the documenttype you want here -->
    <xsl:variable name="level" select="3"/>

    <xsl:template match="/">

    <!-- The fun starts here -->
    <ul>
      <li style="margin:0 0 5px 0;">
        <xsl:variable name="parentPageUrl" select="umbraco.library:NiceUrl($currentPage/parent::*[@isDoc]/@id)" />
       <a href="{$parentPageUrl}">
          <xsl:value-of select="$currentPage/parent::*[@isDoc]/@nodeName" /> 
       </a>
      </li>
    <xsl:for-each select="$currentPage/ancestor-or-self::*[@isDoc and @level = $level]/*[@isDoc and string(umbracoNaviHide) != '1']">
      <li style="margin:0 0 5px 0;">
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </li>
    </xsl:for-each>
    </ul>

    </xsl:template>

    </xsl:stylesheet>

  • Martin Vingaard 39 posts 60 karma points
    May 11, 2011 @ 12:58
    Martin Vingaard
    0

    Now everything works.
    Thanks Jedi masters

Please Sign in or register to post replies

Write your reply to:

Draft