Page 1 of 1

What code to use for submenu in the .xsl file?

Posted: Sun Apr 19, 2015 5:18 pm
by Patrik iden
Hello, i have this code now for a menu whitout any dropdown. How should the code look like for a menu with submenus?

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match='/'>
<ul>
<xsl:for-each select="DATASET/ITEM">
<li><a href="{URL}"><xsl:value-of disable-output-escaping="yes" select="MENUNAME"/></a></li>
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>
And the HTML code for the menu looks like this:

Code: Select all

<div class="nav">
		<div class="rmm">
			<ul>
			<li><a class="active_yes" href="#">HOME</a></li>
				<li>
					<a href="#">BOOKS</a>
					<ul>
						<li>
							<a href="#">AUDIOBOOKS</a>
						</li>
						<li>
							<a href="#">COOKBOOKS</a>
						</li>
						<li>
							<a href="#">CATALOGS</a>
						</li>
						<li>
							<a href="#">OTHER</a>
						</li>
					</ul>
				</li>
				<li>
					<a href="#">DVDS</a>
				</li>
				<li>
					<a href="#">MUSIC</a>
					<ul>
						<li><a href="#">CASSETTES</a></li>
						<li><a href="#">CD</a></li>
						<li><a href="#">RECORDS</a></li>
					</ul>
				</li>
				<li>
					<a href="#">VIDEO GAMES</a>
				</li>
			</ul>
		</div>
	</div>
Thank you.

Re: What code to use for submenu in the .xsl file?

Posted: Sun Apr 19, 2015 5:24 pm
by BaconFries
If memory serves me there is a example of how to write this in the example zip PDF
viewtopic.php?f=42&t=13743

Re: What code to use for submenu in the .xsl file?

Posted: Sun Apr 19, 2015 8:08 pm
by Patrik iden
BaconFries wrote:If memory serves me there is a example of how to write this in the example zip PDF
viewtopic.php?f=42&t=13743
Well the menu example in the link uses menutree and i am using Dataset. I dont know if there is a differens when coding the .xsl file?
Cant fins a .pdf file in the example zip.

Re: What code to use for submenu in the .xsl file?

Posted: Sun Apr 19, 2015 8:19 pm
by BaconFries
In the Edit Properties you should set the Type to Navigation this will then allow you to insert the xsl file so that you/the user can select the main menu items the select any sub menus required. Note again if memory serves you will need to compile the extension first add to WB before it will show it work...I did/do have a extension that I used this method on but never released

Re: What code to use for submenu in the .xsl file?

Posted: Sun Apr 19, 2015 9:27 pm
by Patrik iden
I have this code now bot the generated code is wrong, i get the a href in the code but no Names are gerated. Eg, if i add a Manu item "HOME" i get in the generated code a a href but not the text HOME.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:call-template name="menu" />
</xsl:template>
<xsl:template name="menu">
<ul>
<xsl:apply-templates select="MENU/ITEM" />
</ul>
</xsl:template>
<xsl:template match="ITEM">
<li>
<a href="{URL}"><xsl:value-of disable-output-escaping="yes" select="MENUNAME"/></a>
<xsl:if test="ITEM">
<ul>
<xsl:apply-templates select="ITEM"/>
</ul>
</xsl:if>
</li>
</xsl:template>
</xsl:stylesheet>
The gerated code only looks like this:

Code: Select all

<div class="nav">
<div class="rmm">

<ul>
<li>
<a href=""></a>
</li>
<li>
<a href=""></a>
</li>
<li>
<a href=""></a>
<ul>
<li>
<a href=""></a>
</li>
<li>
<a href=""></a>
</li>
</ul>
</li>
<li>
<a href=""></a>
</li>
<li>
<a href=""></a>
</li>
</ul>

</div>
</div>