Question

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.cshtml

Display 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!

Was it helpful?

Solution

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!!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top