我已经实现了Web部件以支持嵌套转发器,以便使用kentico 8实现大型菜单
我所做的是在网页部分中的转发器之后创建的
<div>
<cms:CMSRepeater ID="CMSRepeater6" runat="server" Path="/%" ClassNames="CMS.MenuItem" OrderBy="NodeOrder" WhereCondition="DocumentMenuItemHideInNavigation = 0 AND Published = 1 AND MenuItemGroup='Top'" MaxRelativeLevel="1" DelayedLoading="true" OnItemDataBound="CMSRepeater6_ItemDataBound" >
<ItemTemplate>
<div>
<li>
<h3><a href="<%# Eval("NodeAliasPath")%>"><%# Eval("DocumentName")%></a></h3>
</li>
</div>
<cms:CMSRepeater ID="repMegaMenuLevel1" runat="server" Path="/%" ClassNames="CMS.MenuItem" OrderBy="NodeOrder">
<ItemTemplate>
</ItemTemplate>
</cms:CMSRepeater>
</ItemTemplate>
</cms:CMSRepeater>
</div>
并尝试在代码级别绑定转换
protected void CMSRepeater6_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;
if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
{
var dr = item.DataItem as DataRowView;
string menuType = dr["MenuItemType"].ToString();
if (!string.IsNullOrEmpty(menuType))
{
var rptMegaMenuItem = item.FindControl("repMegaMenuLevel1") as CMSRepeater;
if (menuType.Equals("1"))
{
rptMegaMenuItem.TransformationName = "Content.PageProductCategory.MagaMenu11";
rptMegaMenuItem.WhereCondition = "MenuItemType = 1 AND MenuItemGroup='Top' AND DocumentMenuItemHideInNavigation = 0 ";
rptMegaMenuItem.NestedControlsID = "repMegaMenuLevel3";
rptMegaMenuItem.DelayedLoading = true;
}
}
}
}
转换代码:
<cms:CMSRepeater ID="repMegaMenuLevel3" runat="server" DataBindByDefault="false" EnableViewState="false" ClassNames="Content.PageProductCategory;CMS.MenuItem" MaxRelativeLevel="1" Path="/What-we-do/%">
<ItemTemplate>
<li><%# Eval("DocumentName")%></li>
<li><%# Eval("DocumentNamePath")%></li>
<li><%# Eval("ClassName")%></li>
</ItemTemplate>
</cms:CMSRepeater>
<script runat="server">
protected override void OnInit(EventArgs e) {
repMegaMenuLevel3.Path = "/What-we-do/%";
repMegaMenuLevel3.ClassNames="Content.PageProductCategory";
repMegaMenuLevel3.ReloadData(true);
}
</script>
问题是转发器repMegaMenuLevel3总是返回文档名称作为父项(CMS.MenuItem)DocumentName即“我们做什么”不是来自content.PageProductCategory,我尝试通过以不同方式设置路径,但没有运气
答案 0 :(得分:0)
我感觉你不必要地设置太多属性:)
如果你想尝试不同的方法,我建议使用分层转换。
资源: