这是关于Razor模板与SDL 2011年SP1。
为了启用SiteEdit UI 2012,我们在CTs中引入了标记。
我想问一下,是否可以为驻留在组件的嵌套嵌入式字段中的字段制作tcdl:ComponentField标记。
这里我们有以"footer_links“作为多值嵌入式字段的组件,而且每个"footer_links”项都有一个多值的嵌入式字段"sub_nav“,并希望读取sub_nav.image使其可编辑。
但是,当我执行以下操作时,为内容TBB启用内联编辑将引发以下错误
错误:对象引用未设置为对象的实例。在Tridion.SiteEdit.Templating.EnableInlineEditingUI.FindItemFieldXPath(String[]部件,Int32 currentIndex,ItemFields字段)
有人知道吗?如果我们能实现这一点呢?如果是,那么下面的代码有什么问题?
另外,我们是否可以阅读ComponentLink中的字段以获得相同的结果?我会感谢你的帮助。
@for (int i=0; i<Fields.footer_links.Count; i++) {
/* "outer_image" is compLink and it workds fine */
@if(Fields.footer_links[i].outer_image != null) {
<tcdl:ComponentField name="Fields.footer_links[@i].outer_image">
<img src="@Fields.footer_links[i].outer_image.ID"/>
</tcdl:ComponentField>
}
/* "sub_nav" is Mutlivalued Embedded field and "image" is field inside it */
@for (int j=0; j<Fields.footer_links[i].sub_nav.Count; j++) {
<li>
@if(Fields.footer_links[i].sub_nav[j].image != null) {
<tcdl:ComponentField name="Fields.footer_links[@i].sub_nav[@j].image">
<img src="@Fields.footer_links[i].sub_nav[j].image.ID" />
</tcdl:ComponentField>
}
}
}发布于 2012-08-29 15:11:02
你能这样做吗?
@foreach(dynamic com in Fields.footer_links) {
/* "outer_image" is compLink and it workds fine */
@if(com.outer_image != null) {
<tcdl:ComponentField name="com.Fields.outer_image">
<img src="@com.Fields.outer_image.ID"/>
</tcdl:ComponentField>
}
/* "sub_nav" is Mutlivalued Embedded field and "image" is field inside it */
@foreach (dynamic subCom in com.sub_nav) {
<li>
@if(subCom.image != null) {
<tcdl:ComponentField name="subCom.Fields.image">
<img src="@subCom.Fields.image.ID" />
</tcdl:ComponentField>
}
}
}因为,下面的@i行似乎不像Int类型那样转换值
<tcdl:ComponentField name="Fields.footer_links[@i].outer_image">发布于 2012-09-05 14:06:31
我假设您在生成tcdl标记时遇到了问题?
要解决这个问题,您可以创建一个助手方法,为您生成标记:
public static MvcHtmlString SiteEditComponentField(this HtmlHelper helper, string id)在此扩展方法中,可以轻松地返回带有标记和属性的格式化字符串。
发布于 2013-01-28 21:14:14
这是很长的时间,所以不确定您使用的是什么,但您当然可以使用剃须刀内建的功能,同样类似dwt。
String RenderComponentField(string fieldExpression, int fieldIndex)
String RenderComponentField(string fieldExpression, int fieldIndex, bool renderTcdlTagOnError)
String RenderComponentField(string fieldExpression, int fieldIndex, string value)
String RenderComponentField(string fieldExpression, int fieldIndex, string value, bool renderTcdlTagOnError)
String RenderComponentField(string fieldExpression, int fieldIndex, bool htmlEncodeResult, bool resolveHtmlAsRTFContent)
String RenderComponentField(string fieldExpression, int fieldIndex, bool htmlEncodeResult, bool resolveHtmlAsRTFContent, renderTcdlTagOnError)谢谢..
https://stackoverflow.com/questions/12175970
复制相似问题