开发者

Orchard Taxonomy not able to override template

开发者 https://www.devze.com 2023-03-22 10:12 出处:网络
I created a simple single level taxonomy, but I cannot override any of the templates. The thing that gives it away is that if I run shape tracing, none of the Taxonomy templates are listed as alterna

I created a simple single level taxonomy, but I cannot override any of the templates.

The thing that gives it away is that if I run shape tracing, none of the Taxonomy templates are listed as alternates. What could this possib开发者_StackOverflow社区ly mean? I am sure I have just missed something simple, but I followed the tutorial step by step.

Any help would be great, thanks.


If it's a module, have you got a placement.info file or at least set Content number in the file? Very simple file but easy to overlook. Is you do try using shape tracer to see if it's been seen at all.


Create a Fields directory under Views in your theme, and create a file named Contrib.TaxonomyField-NameOfTheTaxonomyFieldGoesHere.cshtml. Here is for example the template I'm using to display pretty images to represent the terms, based on a convention I came up with to map the terms to images in the media folder:

@using Orchard.Autoroute.Models
@using Orchard.ContentManagement
@{
    var terms = (IEnumerable<Contrib.Taxonomies.Models.TermPart>)Model.Terms;
}

@if (Model.Terms.Count > 0) {
    <ul class="taxonomy-field labels">
        @foreach(var term in terms) {
            <li>
              <a href="@Href("~/" + term.ContentItem.As<AutoroutePart>().Path)">
                <img src="/media/default/label/@(term.Slug).png"
                     alt="@term.Name" title="@term.Name"/>
              </a>
            </li>
        }
    </ul>
}
0

精彩评论

暂无评论...
验证码 换一张
取 消