Click here to Skip to main content
5,785,816 members and growing! (18,371 online)
Email Password   helpLost your password?
Web Development » ASP.NET » General License: The GNU General Public License (GPL)

OpenCube QuickMenu and Web.sitemap

By ykorotia

How very last Open Cube very dynamic menu can be used with ASP .NET Web.sitemap
C#, .NET, Dev

Posted: 20 Nov 2008
Updated: 20 Nov 2008
Views: 3,087
Bookmarked: 14 times
Note: This is an unedited reader contribution
Announcements
Loading...



Search    
Advanced Search
Sitemap
1 vote for this Article.
Popularity: 0.00 Rating: 4.00 out of 5
0 votes, 0.0%
1
0 votes, 0.0%
2
0 votes, 0.0%
3
1 vote, 100.0%
4
0 votes, 0.0%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article
t

Introduction 

Maybe you hear about http://www.opencube.com/ and their menu projects.. Cool, really cool. BUT their cool menu stays on its own. So 2 classes were implemented to learn their menu 'talk' with Web.sitemap file of ASP .NET web application.  This menu is generated using HTML comfortable class ykorotia_eu.Web.HTMLwriter, with code snippet assigned in ykorotia_eu.OpenCube.QuickMenu.

Working example you can see on personal page: ykorotia.eu

Using the code

Test & working page with their menu:  

======== Default.aspx =======
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

<link href="OpenCube_QuickMenu/1.css" rel="stylesheet" type="text/css" />
<script src="OpenCube_QuickMenu/MenuInit.js" type="text/javascript"></script>
<script src="OpenCube_QuickMenu/Core.js" type="text/javascript"></script>
    <script src="OpenCube_QuickMenu/Add-On/RoundedItems.js" type="text/javascript"></script>

    <script src="OpenCube_QuickMenu/Add-On/RoundedCorners.js" type="text/javascript"></script>
    <script src="OpenCube_QuickMenu/Add-On/MergeAnimation.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <%=ykorotia_eu.OpenCube.QuickMenu.GetMenuFromSitemap() %>      

<script type="text/javascript">
    qm_create(0, false, 0, 500, false, false, false, false, false);
    </script>
    
    DEFAULT
    
    
    </div>
    </form>
</body>
</html>
		

In background Menu looks like this:

==== QuickMenu.cs ====
        public static string GetMenuFromSitemap()
        {
            SitemapLevel lvl = SitemapLevel.three;



            string qmDivider = "[qmDivider]";
            string qmTitle = "[qmTitle]";
            string qmCss_Parent = "qmparent";

            StringBuilder sb = new StringBuilder();
            ykorotia_eu.Web.HTMLwriter wri = new ykorotia_eu.Web.HTMLwriter();

            //prelude
            //<ul id="qm0" class="qmmc"
            sb.Append(wri.AddTag("ul","qmmc","", "qm0"));

            // Doing from ROOT and so on
            //p.s. Root node is hidden
            if (SiteMap.RootNode.HasChildNodes && lvl >= SitemapLevel.one)
            { ........

where SitemapLevel allows you to assign how deep should be read menu nodes from Web.sitemap.

To enable features like 'title', 'divider line', here description parameter is used:

==== Web.sitemap ====
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
  <siteMapNode url="~/" title="root"  description="">
    <siteMapNode url="~/1/1.aspx" title="I-CONTENT"  description="">
      <siteMapNode title="Online Tools" url="~/1" description="[qmTitle] | [qmDivider]" />
        <siteMapNode title="Online Tools" url="~/1/" >
        <siteMapNode title="IPv4toNumber" url="~/1/2.aspx"/>
      </siteMapNode>
    </siteMapNode>
  </siteMapNode>

</siteMap>  

 Deepest html generation starts in HTMLwriter.cs 

Web.sitemap needs to have unique urls, but sometimes first links in menu should be non-clickable. You can gain it by placing this code in QuickMenu.cs

.....            
// Doing from ROOT and so on
            //p.s. Root node is hidden
            if (SiteMap.RootNode.HasChildNodes && lvl >= SitemapLevel.one)
            {
                //=== 1st LEVEL ===
                #region 1st level
                foreach (SiteMapNode child_nodes1 in SiteMap.RootNode.ChildNodes)
                {
                    // main menu nodes
                    sb.Append(wri.AddTag("li") + wri.AddLink(child_nodes1.Title, 
                        //child_nodes1.Url - ignoring url in web.sitemap
                        "javascript:void(0);", 
                        qmCss_Parent, "", false));
..... 

History

First version.  Added some tip

Platinum members can improve this article.

Article is under GNU GPL, willing to leave open source open. Logically?

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPL)

About the Author

ykorotia



Location: Ukraine Ukraine

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
  (Refresh) 
-- There are no messages in this forum --

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 20 Nov 2008
Editor: Sean Ewington
Copyright 2008 by ykorotia
Everything else Copyright © CodeProject, 1999-2009
Web10 | Advertise on the Code Project