Orchard CMS:自定义分类视图模板不起作用
我在自定义内容类型之一中使用分类部分,并使用形状跟踪器,我能够为该控件创建自定义视图模板(Fields.Contrib.TaxonomyField.cshtml)。
当我在页面上塑造跟踪元素时,在模板下,它确实显示了我的自定义模板,就像我在外部文件上一样:
@using Orchard.Utility.Extensions;
@using Orchard.ContentManagement;
@{
var terms = (IEnumerable<Contrib.Taxonomies.Models.TermPart>)Model.Terms;
string name = @Model.ContentField.Name;
}
@if (Model.Terms.Count > 0) {
@(new HtmlString( string.Join(", ", terms.Select(t => Html.ItemDisplayLink(Html.Encode(t.Name), t.ContentItem ).ToString()).ToArray()) ))
}
<div>TEST TEXT</div>
但是,当我切换到实际输出的 HTML 时,它显示的是标准的内置模板,并且没有使用我的自定义设置。
<p class="taxonomy-field">
<a href="/categories/coffee-shop">Coffee Shop</a>
</p>
根据形状追踪器,它正在使用我的自定义模板:
形状字段_Contrib_TaxonomyField
活动模板 〜/Themes/Continuum/Views/Fields.Contrib.TaxonomyField.cshtml
显示类型详细信息
这感觉像是一个错误...一切看起来都已正确连接...还有其他我需要做的事情才能使用我的分类法自定义视图模板?
非常感谢!
I'm using a taxonomy part in one of my custom content types, and using the shape tracer, I was able to create a custom view template for that control (Fields.Contrib.TaxonomyField.cshtml).
When I shape trace the element on the page, under template it indeed shows my custom template exactly as I have it on the external file:
@using Orchard.Utility.Extensions;
@using Orchard.ContentManagement;
@{
var terms = (IEnumerable<Contrib.Taxonomies.Models.TermPart>)Model.Terms;
string name = @Model.ContentField.Name;
}
@if (Model.Terms.Count > 0) {
@(new HtmlString( string.Join(", ", terms.Select(t => Html.ItemDisplayLink(Html.Encode(t.Name), t.ContentItem ).ToString()).ToArray()) ))
}
<div>TEST TEXT</div>
However, when I tab over to the actual outputted HTML, it is showing the standard, built in template, and isn't using my customizations.
<p class="taxonomy-field">
<a href="/categories/coffee-shop">Coffee Shop</a>
</p>
According to the shape tracer, it is using my custom template:
Shape Fields_Contrib_TaxonomyField
Active Template
~/Themes/Continuum/Views/Fields.Contrib.TaxonomyField.cshtmlDisplay Type Detail
this feels like a bug... everything looks like it's wired up correctly... is there something else I need to do to use my custom view template for taxonomy?
Many thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了问题所在。事实证明,创建了另一个模板(可能是偶然的),它是特定于 url 的:
Fields.Contrib.TaxonomyField-url-venues.cshtml
,这是我所在的 url,并且其中仍然包含默认模板。删除之后,终于用了我自定义的模板了。
用户错误,抱歉!!
I figured out the problem. Turns out there was another template created (likely by accident) which was url-specific:
Fields.Contrib.TaxonomyField-url-venues.cshtml
that's the url I was on, and this had the default template still in it. After deleting it, it finally used my custom template.
User error, sorry!!