Posted By

wolulcmit on 04/12/11


Tagged

47 umbraco


Versions (?)

menu test


 / Published in: XSLT
 

URL: umbracotest

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
  3. <xsl:stylesheet
  4. version="1.0"
  5. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  6. xmlns:msxml="urn:schemas-microsoft-com:xslt"
  7. xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary" xmlns:umbraco.contour="urn:umbraco.contour" xmlns:CWS.Twitter="urn:CWS.Twitter" xmlns:ucomponents.cms="urn:ucomponents.cms" xmlns:ucomponents.dates="urn:ucomponents.dates" xmlns:ucomponents.io="urn:ucomponents.io" xmlns:ucomponents.media="urn:ucomponents.media" xmlns:ucomponents.members="urn:ucomponents.members" xmlns:ucomponents.nodes="urn:ucomponents.nodes" xmlns:ucomponents.search="urn:ucomponents.search" xmlns:ucomponents.strings="urn:ucomponents.strings" xmlns:ucomponents.urls="urn:ucomponents.urls" xmlns:ucomponents.xml="urn:ucomponents.xml"
  8. exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib BlogLibrary umbraco.contour CWS.Twitter ucomponents.cms ucomponents.dates ucomponents.io ucomponents.media ucomponents.members ucomponents.nodes ucomponents.search ucomponents.strings ucomponents.urls ucomponents.xml ">
  9.  
  10.  
  11. <xsl:output method="xml" omit-xml-declaration="yes"/>
  12.  
  13. <xsl:param name="currentPage"/>
  14.  
  15. <xsl:template match="/">
  16. <!-- only output markup if we're at level 2 which has subpages -->
  17. <xsl:if test="$currentPage/ancestor-or-self::*[@level=2]/*[@isDoc]">
  18. <div class="glossymenu">
  19. <!-- top level link -->
  20. <xsl:variable name="toplevel" select="$currentPage/ancestor-or-self::*[@level=2]"/>
  21. <xsl:if test="$toplevel">
  22. <a class="menuitem" href="{umbraco.library:NiceUrl($toplevel/@id)}"><xsl:value-of select="$toplevel/@nodeName" /></a>
  23. </xsl:if>
  24.  
  25. <!-- other links and submenu if at level 2 -->
  26. <xsl:apply-templates select="$currentPage/ancestor-or-self::*[@level=2]/*[@isDoc]" />
  27.  
  28. <!--match if we're at the top level (level 0) and we stil want to match for level 1 or 2 -->
  29. <xsl:apply-templates select="$currentPage/descendant::*[@level=2]/*[@isDoc]" />
  30. </div>
  31. </xsl:if>
  32. </xsl:template>
  33.  
  34. <!-- match regardless of level - our normal links -->
  35. <xsl:template match="*[@isDoc]">
  36. <xsl:variable name="currentNode" select="."/>
  37. <!-- only output anything if there are nodes below the currently matched one -->
  38. <xsl:if test="$currentNode/*[@isDoc]">
  39. <a class="menuitem" href="{umbraco.library:NiceUrl(@id)}">
  40. <xsl:value-of select="@nodeName" />
  41. </a>
  42. </xsl:if>
  43. </xsl:template>
  44.  
  45.  
  46. <!-- match pages at level 2 - our normal links and submenu if there is one -->
  47. <xsl:template match="*[@level=2]/*[@isDoc]">
  48. <xsl:variable name="currentNode" select="."/>
  49. <a class="menuitem" href="{umbraco.library:NiceUrl(@id)}">
  50. <!-- output an extra class if there are children below this node -->
  51. <xsl:if test="$currentNode/*[@isDoc]"><xsl:attribute name="class">menuitem submenuheader</xsl:attribute></xsl:if>
  52. <xsl:value-of select="@nodeName" />
  53. </a>
  54.  
  55. <!-- only output submenu code if there are children below this node -->
  56. <xsl:if test="$currentNode/*[@isDoc]">
  57. <div class="submenu">
  58. <ul>
  59. <!-- match pages at level 3 -->
  60. <xsl:apply-templates select="$currentNode/descendant-or-self::*[@level=3]/*[@isDoc]" />
  61. </ul>
  62. </div>
  63. </xsl:if>
  64. </xsl:template>
  65.  
  66. <!-- match pages at level 3 -->
  67. <xsl:template match="*[@level=3]/*[@isDoc]">
  68. <xsl:variable name="currentNode" select="."/>
  69. <li>
  70. <a href="{umbraco.library:NiceUrl(@id)}">
  71. <xsl:value-of select="@nodeName" />
  72. </a>
  73. </li>
  74. </xsl:template>
  75.  
  76. <!-- Only output pages that are not hidden -->
  77. <xsl:template match="*[umbracoNaviHide = 1]" />
  78.  
  79.  
  80. </xsl:stylesheet>

Report this snippet  

You need to login to post a comment.