Sitecore导航用户控件?

时间:2014-09-23 01:06:26

标签: sitecore

你能否提供一些使用用户控件而不是xslt渲染在sitecore中导航的工作示例,因为我在sitecore sdn上找不到好的?

感谢

1 个答案:

答案 0 :(得分:1)

一个例子:

http://www.launchsitecore.net/en/about-launch-sitecore/building-the-site/creating-the-site-menu

<强>标记

<ul class="nav">
    <asp:Repeater ID="rptDropDownMenu" runat="server" OnItemDataBound="rptDropDownMenu_ItemDataBound">
        <ItemTemplate>
            <li id="MenuLi" runat="server">
                <asp:HyperLink ID="MenuLink" runat="server">
                    <asp:Literal ID="MenuText" runat="server" />
                </asp:HyperLink>
                <asp:PlaceHolder ID="phSubMenu" runat="server" />
            </li>
        </ItemTemplate>
    </asp:Repeater>
</ul>

代码背后

HomeItem = SiteConfiguration.GetHomeItem();
List<item> nodes = new List<item>();
if (HomeItem["Show Item In Menu"] == "1") nodes.Add(HomeItem);
foreach (Item i in HomeItem.Children)
{
    if (SiteConfiguration.DoesItemExistInCurrentLanguage(i) && i["Show Item In Menu"] == "1")
    {
        nodes.Add(i);
    }
}
rptDropDownMenu.DataSource = nodes;
rptDropDownMenu.DataBind();