Copied to clipboard

Flag this post as spam?

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


  • Alick Matheson 2 posts 22 karma points
    May 14, 2013 @ 16:35
    Alick Matheson
    0

    top nav

    I'm new to XSLT & Umbraco and wonder if some one can point me in the right direction.

    How would i create this menu using XSLT?

    any help would be much great

            <ul class="Btn">
                <li><a href="en.aspx"><umbraco:Item field="#main nav" runat="server" /></a></li>
                <li><a href="sgoiltean.aspx"><umbraco:Item field="#button 2" runat="server" /></a></li>
                <li><a href="#"><umbraco:Item field="#button 3" runat="server" /></a>
                  <div>
                    <ul>
                <li><a href="bhidiothan.aspx"><umbraco:Item field="#button 4" runat="server" /></a></li>
                          <li><a href="bilinguaslism-matters.aspx"><umbraco:Item field="#button 5" runat="server" /></a></li>
                <li><a href="rannsachadh.aspx"><umbraco:Item field="#button 6" runat="server" /></a></li>
                          <li><a href="fios-is-freagairt.aspx"><umbraco:Item field="#button 7" runat="server" /></a></li>
                          <li><a href="tesisteanasan.aspx"><umbraco:Item field="#button 9" runat="server" /></a></li>
                <li><a href="cothroman-cosnaidh.aspx"><umbraco:Item field="#button 8" runat="server" /></a></li>
                         
                    </ul>
                  </div>
                </li>
                <li><a href="ceistean.aspx"><umbraco:Item field="#button 10" runat="server" /></a></li>
                <li><a href="ceanglaichean.aspx"><umbraco:Item field="#button 11" runat="server" /></a></li>
              </ul>

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    May 15, 2013 @ 01:03
    Chriztian Steinmeier
    1
    Hi Alick - welcome to the forums,
    First of all, this looks like a hardcoded menu - though - using the built-in Dictionary... and by the URLs I'm guessing you have all the pages at the same level, though your menu structure seems to suggest a nested hierarchy.
    Here's a direct "port" of your code - it's not utilizing the power of XSLT (traversing the tree, etc.) but I'm guessing you want to get there next:
    <?xml version="1.0" encoding="utf-8" ?>
    <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:umb="urn:umbraco.library"
        exclude-result-prefixes="umb"
    >
    
        <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
    
        <xsl:param name="currentPage" />
    
        <!-- Use the name of the parent DictionaryItem here -->
        <xsl:variable name="labels" select="umb:GetDictionaryItems('PARENT_KEY')/DictionaryItems/DictionaryItem" />
    
        <xsl:template match="/">
            <ul class="Btn">
                <li><a href="en.aspx"><xsl:value-of select="$labels[@key = 'main nav']" /></a></li>
                <li><a href="sgoiltean.aspx"><xsl:value-of select="$labels[@key = 'button 2']" /></a></li>
                <li>
                    <a href="#"><xsl:value-of select="$labels[@key = 'button 3']" /></a>
                    <div>
                        <ul>
                            <li><a href="bhidiothan.aspx"><xsl:value-of select="$labels[@key = 'button 4']" /></a></li>
                            <li><a href="bilinguaslism-matters.aspx"><xsl:value-of select="$labels[@key = 'button 5']" /></a></li>
                            <li><a href="rannsachadh.aspx"><xsl:value-of select="$labels[@key = 'button 6']" /></a></li>
                            <li><a href="fios-is-freagairt.aspx"><xsl:value-of select="$labels[@key = 'button 7']" /></a></li>
                            <li><a href="tesisteanasan.aspx"><xsl:value-of select="$labels[@key = 'button 9']" /></a></li>
                            <li><a href="cothroman-cosnaidh.aspx"><xsl:value-of select="$labels[@key = 'button 8']" /></a></li>
                        </ul>
                    </div>
                </li>
                <li><a href="ceistean.aspx"><xsl:value-of select="$labels[@key = 'button 10']" /></a></li>
                <li><a href="ceanglaichean.aspx"><xsl:value-of select="$labels[@key = 'button 11']" /></a></li>
            </ul>
        </xsl:template>
    
    </xsl:stylesheet>
    You'll need to move your Dictionary Items under a single parent key - substitute the name of that key for the PARENT_KEY in the code.
    /Chriztian
  • Alick Matheson 2 posts 22 karma points
    May 15, 2013 @ 12:05
    Alick Matheson
    0

    Thanks Chriztian

    I've just started working with Umbraco this week. Here's the website structure within the contents section.

    I'm creating a multilingual site.

    Rather than hard coding the URL within the XSLT is there a way of getting the link to the parent page.

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    May 15, 2013 @ 13:01
    Chriztian Steinmeier
    0

    Hi Malick,

    Yes - there's lots of ways to do this dynamically. I suggest you check out the default templates that ships with Umbraco (Developer > right-click XSLT folder and create a new file - choose "List Subpage by Level" and see how that's constructed). They show how to get the URL of a page, and it's name etc.

    Then come back here with any questions you have from looking into that.

    /Chriztian

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies