【发布时间】:2011-09-13 14:25:59
【问题描述】:
一旦启用,我试图从我的模块中将形状插入到我的布局中。我认为 IShapeFactoryEvents 非常适合这个,但是如果在 POST 期间发生这种情况,从这里查询 CMS 会给我一个“TransactionScope 嵌套错误异常”。想知道是否有人再次对我有任何智慧之言?请参阅下面的代码 sn-p。
public void Created(ShapeCreatedContext context)
{
if (context.ShapeType == "Layout")
{
if (!AdminFilter.IsApplied(_services.WorkContext.HttpContext.Request.RequestContext))
{
var route = RouteTable.Routes.GetRouteData(_services.WorkContext.HttpContext);
object location;
if (route.Values.TryGetValue("location", out location))
{
var region = _services.ContentManager.Query("Region")
.Join<RoutePartRecord>()
.Where(x => x.Slug == (string)location)
.Slice(1).FirstOrDefault();
context.Shape.Header.Add(context.New.CurrentRegion(Title: region.As<RoutePart>().Title), "10");
}
context.Shape.Navigation.Add(context.New.RegionSelector(Regions: _services.ContentManager.Query(VersionOptions.Published, "Region").List()), "11");
}
}
}
再次感谢您。你们太棒了。
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-3 content-management-system orchardcms