On this test site http://109.108.155.82/ the left hand menu is populated via an xml package that imports categories from a SQL table. The package code that controls is reads like this (this is not all of it but the part that imports the Categories)
I need to insert a break after the first 4 categories but cannot figure a way how to do this. Any ideas?
deanswe
Member
18 Points
46 Posts
Breaking up a menu
Jan 29, 2013 12:49 PM|LINK
Hi
On this test site http://109.108.155.82/ the left hand menu is populated via an xml package that imports categories from a SQL table. The package code that controls is reads like this (this is not all of it but the part that imports the Categories)
I need to insert a break after the first 4 categories but cannot figure a way how to do this. Any ideas?
<?xml version="1.0" standalone="yes" ?>
<package version="2.1" displayname="Categories" debug="false" includeentityhelper="false">
<query name="EntityMgr" rowElementName="Entity">
<sql>
<![CDATA[
exec GetMenuItems 'category', 1, 1
]]>
</sql>
</query>
<PackageTransform>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aspdnsf="urn:aspdnsf" xmlns:nutri="urn:nutri" exclude-result-prefixes="aspdnsf nutri">
<xsl:output method="html" omit-xml-declaration="yes"/>
<xsl:param name="CategoryID">
<xsl:choose>
<xsl:when test="nutri:getEntityName(/root/System/PageName) = 'category' and nutri:getEntityID(/root/System/PageName) != 0">
<xsl:value-of select="nutri:getEntityID(/root/System/PageName)"/>
</xsl:when>
<xsl:when test="nutri:getEntityName(/root/System/PageName) = 'product' and boolean(/root/Cookies/lastviewedcategoryid)">
<xsl:value-of select="/root/Cookies/lastviewedcategoryid"/>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:template match="/">
<ul class="l_menu" id="navmenu">
<xsl:for-each select="/root/EntityMgr/Entity[ParentEntityID=0]">
<!-- Begin Root Level Categories-->
<xsl:variable name="EntityID" select="EntityID"/>
<xsl:variable name="Name" select="aspdnsf:GetMLValue(Name)"/>
<xsl:choose>
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Breaking up a menu
Jan 31, 2013 12:22 AM|LINK
Hi,
You can use Xdocument (since net framework 3.5+) or XmlDocument to deal with the problem by:
1) Looking up where to insert by using XmlDocument's SelectNodes (for many nodes) or SelectSingleNode (for a single node).
2) Then use AppendChild to add an element node.
3) In the end, call Save to solve your problem by re-writting the whole xml contents.