Copied to clipboard

Flag this post as spam?

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


  • Mark W. Nielsen 13 posts 33 karma points
    Aug 12, 2011 @ 13:18
    Mark W. Nielsen
    0

    Change menu item depending on nodeName

    Hello fellow Umbraco-holics,

    I got a little issue with my menu on my site. i got my site in 3 different language, DK, DE and UK. On each site there is a page called the following things:

    DK: Brochure
    UK: Download
    DE: Downloads

    I generate my menu automaticly with the fllowing XSLT macro:

    <xsl:template match="/">
     
    <!-- The fun starts here -->
      <div class="menu_item">
        <xsl:if test="$currentPage/ancestor-or-self::*[@isDoc and @nodeName='UK']">
          <class="menu_link" href="/">
            <xsl:choose>
              <xsl:when test="$currentPage/self::Frontpage">
                <b><u>Home</u></b>
              </xsl:when>
              <xsl:otherwise>
                Home
              </xsl:otherwise>
            </xsl:choose>
          </a>
        </xsl:if>
        <xsl:if test="$currentPage/ancestor-or-self::*[@isDoc and @nodeName='DK']">
          <class="menu_link" href="/dk.aspx">
            <xsl:choose>
              <xsl:when test="$currentPage/self::Frontpage">
                <b><u>Forside</u></b>
              </xsl:when>
              <xsl:otherwise>
                Forside
              </xsl:otherwise>
            </xsl:choose>
          </a>
        </xsl:if>
        <xsl:if test="$currentPage/ancestor-or-self::*[@isDoc and @nodeName='DE']">
          <class="menu_link" href="/de.aspx">
            <xsl:choose>
              <xsl:when test="$currentPage/self::Frontpage">
                <b><u>Startseite</u></b>
              </xsl:when>
              <xsl:otherwise>
                Startseite
              </xsl:otherwise>
            </xsl:choose>
          </a>
        </xsl:if>
      </div>
      <xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc and @level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
      <div class="menu_item">
        <class="menu_link" href="{umbraco.library:NiceUrl(@id)}">
          <xsl:choose>
            <xsl:when test="$currentPage/ancestor-or-self::*/@id = current()/@id">
              <b><u><xsl:value-of select="@nodeName"/></u></b>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="@nodeName"/>
            </xsl:otherwise>
          </xsl:choose>
        </a>
      </div>
    </xsl:for-each>
      
    </xsl:template>

    What i need to do is, when the macro reach on of the page I've told about further up i want to be able to output something else. I managed to do it with the following code:

    <xsl:if test="@nodeName ='Brochure'">
        Download
    </xsl:if>

    The problem is that it only workds when I'm on the Brochure page, and I need it to display "Download" no matter what page i'm on. I hope you guys can help me!

    Regards,
    Mark W. Nielsen

     

     

     

     

     

     

     

     

     

     

     

     

     

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 12, 2011 @ 13:47
    Fuji Kusaka
    0

    Hi Mark, 

    Are you trying to display something else when hovering on a menu node?

    If so what you can do is change this 

    <xsl:if test="@nodeName ='Brochure'">
        Download
    </xsl:if>

    to

    <xsl:when test="@id = 'youNodeID'">
    What ever you need to do
    </xsl:when>

     

    //fuji

  • Mark W. Nielsen 13 posts 33 karma points
    Aug 12, 2011 @ 13:52
    Mark W. Nielsen
    0

    Hey (again) Fuji,

    Not excatly what I'm trying to achive. What I want is to permanente chage the displaying text for the node called "Brochure" no matter what page on my site I'm on. If you want to see the structure of my site, just let me know.

     

    //Mark W. Nielsen :P

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 12, 2011 @ 14:07
    Fuji Kusaka
    0

    Please do so....

     

    //fuji

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 12, 2011 @ 14:09
    Tom Fulton
    0

    A little confused on exactly what you want, but wouldn't this be what you want?

    <xsl:if test="@nodeName ='Brochure' or @nodeName = 'Downloads' or @nodeName = 'Download'">
        Download
    </xsl:if>

    Also, generally speaking it's probably not the best practice to go by the nodeName since it can be changed by editors (maybe not in your case)?  If that page has its own document type you can test for that, and you'd only need one condition since all 3 sites would use the same doctype:

    <xsl:if test="local-name() = 'YourDocTypeAlias'">
      Download
    </xsl:if>

    -Tom

  • Mark W. Nielsen 13 posts 33 karma points
    Aug 12, 2011 @ 14:24
    Mark W. Nielsen
    0

    Hey Tom,

    That was excatly what i was after! And thanks for the heads up on checking on Document type instead of nodeName. I could use the other one in another place on my site :)

    You got your post marked as solution.

    \\Mark W.

Please Sign in or register to post replies

Write your reply to:

Draft