-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget.navigation.xsl
110 lines (94 loc) · 2.79 KB
/
get.navigation.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--
Navigation Templates
Provides navigation based on page type
@package Utility Monkey
@author John Porter <[email protected]>
@license CC0 <http://creativecommons.org/publicdomain/zero/1.0/>
-->
<!--
Template for navigation
Uses a standard Symphony Navigation Datasource
@param page-type Specify a page type to limit menu to
@param classes Class names to apply to all ul elements
-->
<xsl:template match="*" mode="navigation">
<xsl:param name="page-type"/>
<xsl:param name="classes"/>
<nav>
<xsl:attribute name="class">
navigation
<xsl:if test="$page-type">
<xsl:text> </xsl:text>
<xsl:value-of select="$page-type"/>
</xsl:if>
</xsl:attribute>
<ul>
<xsl:if test="$classes">
<xsl:attribute name="class">
<xsl:value-of select="$classes"/>
</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="$page-type">
<xsl:apply-templates select="page[types/type = $page-type and not(types/type = 'hidden')]" mode="navigation">
<xsl:with-param name="classes" select="$classes"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="page[not(types/type = 'hidden')]" mode="navigation">
<xsl:with-param name="classes" select="$classes"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</ul>
</nav>
</xsl:template>
<!--
Template for single navigation links
Uses a standard Symphony Navigation Datasource
@param classes Class names to apply to all ul elements
-->
<xsl:template match="page" mode="navigation">
<xsl:param name="classes"/>
<xsl:variable name="page-url">
<xsl:choose>
<xsl:when test="types/type = 'index'">
<xsl:value-of select="concat($root,'/')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($root,'/',@handle,'/')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<li>
<xsl:attribute name="class">
<xsl:for-each select="types/type">
<xsl:text> </xsl:text>
<xsl:value-of select="@handle"/>
</xsl:for-each>
</xsl:attribute>
<a href="{$page-url}">
<xsl:if test="@handle = $current-page or @handle = $root-page">
<xsl:attribute name="class">active</xsl:attribute>
</xsl:if>
<xsl:value-of select="name"/>
</a>
<xsl:if test="page and not(page/types/type = 'hidden')">
<nav class="navigation nested">
<ul>
<xsl:if test="$classes">
<xsl:attribute name="class">
<xsl:value-of select="$classes"/>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="page[not(types/type = 'hidden')]">
<xsl:with-param name="classes" select="$classes"/>
</xsl:apply-templates>
</ul>
</nav>
</xsl:if>
</li>
</xsl:template>
</xsl:stylesheet>