Copied to clipboard

Flag this post as spam?

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


  • Hundebol 167 posts 314 karma points
    Sep 07, 2009 @ 09:15
    Hundebol
    0

    Show only THE parent of the node

    Hi,

    I have a structure like this:

    news
    -- 2009
    ---- august

    On the "August" page, i want to display the the month and year.

    I show the month by nodename like this:

    <xsl:value-of select="@nodeName" disable-output-escaping="yes"/>

    But what if i want to show the nodename of the parent.

    I have tried with a for-each statement with the level of the 2009-node - but then when i add for instance year 2010, the for each show both years (of course)

    But how to ONLY show THE parent of August?

    best regards,
    Brian

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 07, 2009 @ 09:28
    Dirk De Grave
    3

    Hi Brian,

     

    If you need a reference to the parent and display the node name, use 

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

    or

    <xsl:value-of select="$currentPage/parent::node/@nodeName"/>

     

    Also, take a look at this wiki page

     

    Cheers,

    /Dirk

  • Hundebol 167 posts 314 karma points
    Sep 07, 2009 @ 12:20
    Hundebol
    0

    Hi Dirk,

    I confused my self a bit apparently!

    My Macro is really on the News page. And on this page i want to show the parent of the August page - in this example the 2009 page.

    Is that possible?

    best regards
    Brian

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 07, 2009 @ 12:52
    Dirk De Grave
    0

    Hi Brian,

    Show us the complete xslt, so we can get hold of the context. It's quite easy to get the 2009 page from the August page, but it all depends how you get to the August page first? So, willing to share that bit of code?

     

    Cheers,

    /Dirk

  • Hundebol 167 posts 314 karma points
    Sep 07, 2009 @ 13:08
    Hundebol
    0

    Hi Dirk,

    It's a rather long xslt file. to sum up, i have a structure like this:

    news page (My Macro is on this page!)
    ---- 2009
    ----- august
    ---- 2010
    ----- september

    And so on!
    On the news page i want to display the nodename of the August, September and all the other months/nodes above an image. This Works. But I would also like to show the correct year = so that it will displat August 2009 and September 2010.

    The XSLT is probabably not "best practice" - but it works. Suggetions are appreciated though :)

     

        <xsl:output method="html" omit-xml-declaration="yes"/>
        <xsl:param name="currentPage"/>
        <xsl:variable name="maxItems" select="/macro/maxItems"/>
        <xsl:param name="MaxNoChars" select="150" />
        <xsl:variable name="level" select="4"/>
        <xsl:template match="/">

    <xsl:for-each select="$currentPage/descendant-or-self::node [@level=$level]/node [string(data [@alias='umbracoNaviHide']) != '1']">
       <!-- THE IF, WILL TEST HOW MANY ITEMS TO SHOW -->
        <xsl:if test="position() &lt;= $maxItems">
            <h2>
           
    <!-- Month - taken from the node name-->
            <xsl:value-of select="@nodeName" disable-output-escaping="yes"/>

                    <!-- Year - taken from the node/folder name-->               

                    </h2>
                   <!-- THE PHOTO OF THE NEWS MAGAZINE -->
                <xsl:variable name="englishfile" select="umbraco.library:GetMedia(number(./data[@alias='BWnewsFile']),'false')"/>
                    <a href="{$englishfile/data[@alias='umbracoFile']}">
                    <img style="border: none;">
                    <xsl:attribute name="src">
                    <xsl:value-of select="umbraco.library:GetMedia(data [@alias = 'BWnewsPhoto'], 'false')/data [@alias = 'umbracoFile']"/>
                    </xsl:attribute>
                    </img>  
                </a>
          
            <br />
            <!-- THE DANISH PDF FILE OF THE NEWS MAGAZINE -->
            <!-- FIRST SHOW THE PDF LOGO FROM THE MEDIA LIBRARY -->
            <img>
            <xsl:attribute name="src">
            <xsl:value-of select="umbraco.library:GetMedia(1497, 'false')/data [@alias = 'umbracoFile']"/>
            </xsl:attribute>
            </img>
            <!-- REMEMBER THE SPACE BETWEEN THE PDF LOGO AND THE LINK -->
            &nbsp;
            <!-- THEN SHOW THE LINK TO THE DANISH FILE -->
            <xsl:variable name="danishfile" select="umbraco.library:GetMedia(number(./data[@alias='BWnewsFileDanish']),'false')"/>
                    <a href="{$danishfile/data[@alias='umbracoFile']}">In danish</a>
    </xsl:if>  
    </xsl:for-each

     

    Best regards,

    Brian

  • Nico 9 posts 34 karma points
    Sep 07, 2009 @ 14:05
    Nico
    0

    Hi Brian,

    It's like dirk said.

    <h2>
    <xsl:value-of select="@nodeName" disable-output-escaping="yes"/> 
    <xsl:value-of select="../@nodeName" disable-output-escaping="yes"/> 
    </h2>

    Cheers,

    Nico

  • Hundebol 167 posts 314 karma points
    Sep 07, 2009 @ 14:23
    Hundebol
    0

    Hi Nico!

    Thanks a bunch. Simple, simple, simple.

    best regards
    Brian

Please Sign in or register to post replies

Write your reply to:

Draft