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

This section can be used to submit suggestions for Extension Builder.
Note that this section is not monitored for support.
Forum rules
This forum section can be used to submit suggestions for Extension Builder.
Note that this section is not monitored for support.
Post Reply
User avatar
Patrik iden
 
 
Posts: 479
Joined: Wed Mar 24, 2010 9:07 pm
Location: Sweden

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

Post 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.
User avatar
BaconFries
 
 
Posts: 5316
Joined: Thu Aug 16, 2007 7:32 pm

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

Post 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
User avatar
Patrik iden
 
 
Posts: 479
Joined: Wed Mar 24, 2010 9:07 pm
Location: Sweden

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

Post 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.
User avatar
BaconFries
 
 
Posts: 5316
Joined: Thu Aug 16, 2007 7:32 pm

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

Post 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
User avatar
Patrik iden
 
 
Posts: 479
Joined: Wed Mar 24, 2010 9:07 pm
Location: Sweden

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

Post 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>
Post Reply