我有一个子应用程序 (YetAnotherForum.NET) 位于我的 Composite C1 站点的子目录中。为了保持一致的外观和感觉,我想为导航元素引入 C1 函数。
注意:下面代码中的所有 html 标记都将尖括号替换为方括号,以便在此处发布。
我发现我可以使用以下语法调用 C1 函数:
[f:function ID="Function1" name="Custom.Layout.FooterLinks" runat="server"/]
但是,该函数背后的数据似乎不可用。任何想法数据问题可能是什么?也许我需要外部页面从某种形式的复合 C1 页面继承?
这是功能代码:
@使用复合数据;
@使用复合数据类型;
@使用 Composite.Data.ProcessControlled.ProcessControllers.GenericPublishProcessController;
@使用 CompositeC1Contrib.RazorFunctions;
@inherits CompositeC1WebPage
@功能 {
私有 IEnumerable FooterLinkPages()
{
IEnumerable pages = DataFacade.GetData();
IEnumerable returnPages;
使用(数据连接连接 = 新数据连接())
{
returnPages = (from l in connection.Get()
在 l.Page 上的页面中加入 p 等于 p.Id
其中 l.PublicationStatus == GenericPublishProcessController.Published
&& p.PublicationStatus == GenericPublishProcessController.Published
orderby l.位置升序
选择 p).ToList();
}
返回返回页;
}
}
[ul class="unstyled"]
@foreach(FooterLinkPages() 中的 IPage 页面)
{
[li]@(String.IsNullOrWhiteSpace(page.MenuTitle) ? page.Title : page.MenuTitle)[/a][/li]
}
[/ul]