Copied to clipboard

Flag this post as spam?

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


  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 27, 2011 @ 14:41
    Fuji Kusaka
    0

    GetXmlNodeById to display Parent

    Hi,

    I have a macro which needs to be place 3 times on the same template where each of them have a different source id(folder).

    Just like a basic Xslt  

    <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
     
        <li>
       
    <a href="{umbraco.library:NiceUrl(@id)}">
         
    <xsl:value-of select="@nodeName"/>
       
    </a>
      </li>
    </
    xsl:for-each>

    but my question is how do i get to display the parent node as a heading?

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Sep 27, 2011 @ 17:59
    Chriztian Steinmeier
    0

    Hi Fuji,

    Do you mean the parent of $source or the $source node itself?

    The first would be:

    <h1><xsl:value-of select="$source/../@nodeName" /></h1>

    whereas the second would be: 

    <h1><xsl:value-of select="$source/@nodeName" /></h1>

    - but maybe that's not what you mean?

    /Chriztian

  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 27, 2011 @ 18:26
    Fuji Kusaka
    0

    Hi Chriztian,

    I would like to display the nodeName of the source i choose. But I dont need to see  it in my loop.

    I tried both your suggestions but not working. However this works for me, but still need to get to work outside the loop

         <h1><xsl:value-of select="./../@nodeName" /></h1>

    //fuji

  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 27, 2011 @ 18:49
    Fuji Kusaka
    0

    Chriztian,

    I got it working this way

    <xsl:value-of select="umbraco.library:GetXmlNodeById($source)/@nodeName"/>

    But thanks for helping me out

  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 27, 2011 @ 20:03
    Fuji Kusaka
    0

    Can you help me out with this chriztian,

    I know this can be done by using the umbracoRedirect but i rather use something like if there is a child node then jump to the child node when clicking on the parent node by using a True/false statement.

    Here is my XLST but can get it working

          <a>
             <xsl:attribute name="href">
               <xsl:choose>
                 <xsl:when test="count(umbraco.library:GetXmlNodeById($source)/*[@isDoc]) &gt;1 and string(jumpToSubpage) = '1'">
                   <xs
    l:value-of select="umbraco.library:NiceUrl(./*[@isDoc]/@id)" />
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="umbraco.library:NiceUrl($source)"/>
                </xsl:otherwise>
                </xsl:choose>

           </xsl:attribute>
           <xsl:value-of select="umbraco.library:GetXmlNodeById($source)/@nodeName"/>
         </a>
  • Nigel Wilson 945 posts 2077 karma points
    Sep 27, 2011 @ 20:52
    Nigel Wilson
    1

    Hi Fuji

    Not tested but hopefully correct...

     

     <a>
             <xsl:attribute name="href">
               <xsl:choose>
                 <xsl:when test="count(umbraco.library:GetXmlNodeById($source)/*[@isDoc]) &gt;1 and string(jumpToSubpage) = '1'">
                   <xs
    l:value-of select="umbraco.library:NiceUrl(umbraco.library:GetXmlNodeById($source/@id)/*[@isDoc][1]/@id)" />
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="umbraco.library:NiceUrl($source)"/>
                </xsl:otherwise>
                </xsl:choose>

           </xsl:attribute>
           <xsl:value-of select="umbraco.library:GetXmlNodeById($source)/@nodeName"/>
         </a>

    Adding the [1] gets the first child node...

    Let me know if it works for you.

    Cheers

    Nigel

     

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Sep 27, 2011 @ 20:55
    Chriztian Steinmeier
    0

    Hi Fuji,

    Sorry 'bout the other one - I was thinking in the way I use to do it, like I'll recommend for you here:

    <!-- Only call this once -->
    <xsl:variable name="sourceNode" select="umbraco.library:GetXmlNodeById($source)" />
    <a>
        <xsl:attribute name="href">
            <xsl:choose>
                <!-- If there is at least one childnode and jumpToSubpage is set -->
                <xsl:when test="$sourceNode[*[@isDoc] and jumpToSubpage = 1]">
                    <!-- Link to the first child  -->
                    <xsl:value-of select="umbraco.library:NiceUrl(*[@isDoc][1]/@id)" />
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="umbraco.library:NiceUrl($sourceNode/@id)" />
                </xsl:otherwise>
            </xsl:choose>
        </xsl:attribute>
    
        <xsl:value-of select="$sourceNode/@nodeName" />
    </a>

    /Chriztian

  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 28, 2011 @ 07:48
    Fuji Kusaka
    0

    Hi Chriztian,

    Thanks for the reply. I tried it but not working when i set jumpToSubpage to True in the content node. Its giving me a parsing error

    Its only the URL (link to child) which seems not to work.

    <xsl:value-ofselect="umbraco.library:NiceUrl(*[@isDoc][1]/@id)"/>

    //fuji

  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 28, 2011 @ 07:58
    Fuji Kusaka
    0

    I got it working Chriztian,

    Instead i changed the value from

    <xsl:value-ofselect="umbraco.library:NiceUrl(*[@isDoc][1]/@id)"/>
      <xsl:value-of select="umbraco.library:NiceUrl($sourceNode/*[@isDoc][1]/@id)"/>

    But thanks for helping me out solving it.

    Cheers

    //Fuji

Please Sign in or register to post replies

Write your reply to:

Draft