Rank: Newbie
Joined: 8/8/2008 Posts: 2 Location: Malmoe
|
Hi everyone. I got some issues with my usercontrol which i created few months ago, this is running on a ASP.NET 2.0 webserver and reads from the Web.Sitemap to Databind two repeaters. One repeater for the top-levels and one for the Childs...
Shouldnt i be able to run this on Umbraco v3.0.5?
Been trying with XSLT, and Umbracos NodeFactory...
Im a newbie on Umbracos, used it for 3 days here at work, and been trying to implement this code or some other for similiar behavior without much success.
Anyone got some sample or where to start tip?
Heres the code for my Code-behind:
public class MenuItem { public string Url { get; set; } public string Title { get; set; } public string Descr { get; set; } public string Style { get; set; }
}
protected List<MenuItem> Top; protected List<MenuItem> Bottom; protected void Page_Load(object sender, EventArgs e) { Top = new List<MenuItem>(); Bottom = new List<MenuItem>();
if (SiteMap.CurrentNode.HasChildNodes) {
Top.Add(new MenuItem { Url = SiteMap.CurrentNode.ParentNode.Url, Title = SiteMap.CurrentNode.ParentNode.Title, Style = "lvl2" }); Top.Add(new MenuItem { Url = SiteMap.CurrentNode.Url, Title = SiteMap.CurrentNode.Title, Style = "lvl2_current" }); TopRep.DataSource = Top; TopRep.DataBind();
foreach (SiteMapNode node in SiteMap.CurrentNode.ChildNodes) { Bottom.Add(new MenuItem { Url = node.Url, Title = node.Title, Style="lvlx" }); BottomRep.DataSource = Bottom; BottomRep.DataBind(); }
} else { foreach (SiteMapNode node in SiteMap.CurrentNode.ParentNode.ChildNodes) {
if (node.Url == SiteMap.CurrentNode.Url) { Bottom.Add(new MenuItem { Url = node.Url, Title = node.Title, Style = "lvlx_current" }); } else { Bottom.Add(new MenuItem { Url = node.Url, Title = node.Title, Style = "lvlx" }); } }
Top.Add(new MenuItem { Url = SiteMap.CurrentNode.ParentNode.ParentNode.Url, Title = SiteMap.CurrentNode.ParentNode.ParentNode.Title, Style = "lvl1" }); Top.Add(new MenuItem { Url = SiteMap.CurrentNode.ParentNode.Url, Title = SiteMap.CurrentNode.ParentNode.Title, Style = "lvl2" }); TopRep.DataSource = Top; TopRep.DataBind(); BottomRep.DataSource = Bottom; BottomRep.DataBind();
} And the other part:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Repeater.ascx.cs" Inherits="erhverv_WebUserControl" %>
<asp:Content> <table width="175"> <tr> <td align="left">
<asp:Repeater runat="server" ID="TopRep" onitemcommand="siteMapAsBulletedList_ItemCommand"> <ItemTemplate> <div id='<%# Eval("Style") %>'><asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("Url") %>' Text='<%# Eval("Title") %>'></asp:HyperLink> <img src="http://static.telia.dk/lokalmenu_dashline.gif" alt="None" border="0" /> </div> </ItemTemplate> </asp:Repeater>
<asp:Repeater runat="server" ID="BottomRep" onitemcommand="siteMapAsBulletedList_ItemCommand"> <ItemTemplate> <div id='<%# Eval("Style") %>'><asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("Url") %>' Text='<%# Eval("Title") %>'></asp:HyperLink> </div> </ItemTemplate>
</asp:Repeater>
<img src="http://static.telia.dk/lokalmenu_dashline.gif" alt="None" border="0" /> <span class="grey">Bemærk: Alle priser <br /> er ekskl. moms.</span> </td> </tr> </table> </asp:Content>
|
 Rank: Addict
Joined: 9/27/2007 Posts: 977 Location: Belgium
|
Isn't Web.sitemap in xml format? It would make it a perfect candidate for transforming it using xslt (And using a macro referring to an xslt file rather than a user control). Have a look at this thread on how to start And shoot if you have more questions. Regards, /Dirk
level 1 certified - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
Rank: Newbie
Joined: 8/8/2008 Posts: 2 Location: Malmoe
|
Thanks alot!
I will try to make something out of this. Have searched google apart now :)...
Im keeping the thread updated..
|