sqlSiteMapProvider SiteMapDataSource as XML?

coachoutlet3lxh

New Member
I'm currently fitting a new menu onto an old website platform that uses ASP.NET SqlSiteMapProvider and treeview database table for its current backend menu management.I'd like to keep the backend (admin) structure intact but change the frontend output to match my new needs. However the current frontend uses for outputting the sitemap to a menu, and it is awful and doesn't seem to be able to do the "Mega menu" layout we're going for here.I created a separate XML document for testing and setup my own structure, and XLS to transform it to my needs, se code below.How can I make the ASPTreeView sqlsitemap-thingy output an xml like this one? Or does anyone have a better solution going about the issue? The menu we're trying to achieve is the top menu on Hammarby FotbollXML:<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE root [ <!ELEMENT root (MenuItem*)> <!ELEMENT MenuItem (Column*)> <!ELEMENT Column (ListItem*,Image*)> <!ELEMENT ListItem (#PCDATA)> <!ELEMENT Image (#PCDATA)> <!ATTLIST MenuItem title CDATA #REQUIRED> <!ATTLIST MenuItem url CDATA #IMPLIED> <!ATTLIST Column title CDATA #IMPLIED> <!ATTLIST ListItem url CDATA #IMPLIED> <!ATTLIST ListItem external CDATA #IMPLIED> <!ATTLIST Image url CDATA #REQUIRED> <!ATTLIST Image external CDATA #IMPLIED>]><root> <MenuItem title="Title" url="url.aspx"> <Column title="Title"> <ListItem url="url.aspx">Title</ListItem> <ListItem url="url.aspx">Title</ListItem> <ListItem url="url.aspx">Title</ListItem> <ListItem url="url.aspx" external="1">Title</ListItem> <ListItem url="url.aspx">Title</ListItem> <ListItem url="url.aspx">Title</ListItem> </Column> <Column title="Title"> <ListItem url="url.aspx">Title</ListItem> <ListItem url="url.aspx">Title</ListItem> [etc] </Column> <Column> <Image url="/cmsport/Handlers/Media.aspx?MediaID=1382&Width=200" /> </Column> <Column title="Title"> <ListItem url="url.aspx">Title</ListItem> <ListItem url="url.aspx">Title</ListItem> [etc] </Column> [etc] </MenuItem> <MenuItem title="Title" url="url.aspx"> <Column title="Title"> <ListItem url="url.aspx">Title</ListItem> <ListItem url="url.aspx">Title</ListItem> </Column> <Column title="Title"> <ListItem url="url.aspx">Title</ListItem> <ListItem url="url.aspx">Title</ListItem> </Column> <Column title="Title"> <ListItem url="url.aspx">Title</ListItem> <ListItem url="url.aspx">Title</ListItem> </Column> </MenuItem> [etc]</root>XSLT:<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"> <!-- indicates what our output type is going to be --> <xsl:output method="html" indent="no" /> <!-- Start of with html and first match--> <xsl:template match="/"> <nav id="main-menu"> <ul> <xsl:copy> <xsl:apply-templates select="/*" /> </xsl:copy> </ul> </nav> </xsl:template> <!-- Template for First level menu items--> <xsl:template match="MenuItem"> <li> <a> <xsl:choose> <xsl:when test="@url"> <xsl:attribute name="href"> <xsl:value-of select="@url"/> </xsl:attribute> </xsl:when> <xsl:otherwise> <xsl:attribute name="href">#</xsl:attribute> </xsl:otherwise> </xsl:choose> <xsl:value-of select="@title" /> </a> <xsl:if test="count(Column) > 0"> <div class="megamenu-dropdown"> <xsl:apply-templates select="Column"/> </div> </xsl:if> </li> </xsl:template> <!-- Template for each column in a submenu--> <xsl:template match="Column"> <div class="megamenu-column"> <xsl:if test="@title != ''"> <p> <xsl:value-of select="@title" /> </p> </xsl:if> <xsl:if test="count(Image) > 0"> <p> <img> <xsl:attribute name="src"> <xsl:value-of select="Image/@url" /> </xsl:attribute> </img> </p> </xsl:if> <xsl:if test="count(ListItem) > 0"> <ul> <xsl:for-each select="ListItem"> <li> <a> <xsl:attribute name="href"> <xsl:value-of select="@url"/> </xsl:attribute> <xsl:if test="@external = 1"> <xsl:attribute name="target"> _blank </xsl:attribute> </xsl:if> <xsl:value-of select="."/> </a> </li> </xsl:for-each> </ul> </xsl:if> </div> </xsl:template></xsl:stylesheet>
 
Back
Top