문제

I'm trying to display a List of my taxonomies with a count of content items in it.

But i can't find out how to do it. i tried to modify TaxonomyItem.cshtml

var terms = (IEnumerable<Orchard.Taxonomies.Models.TermPart>)Model.Taxonomy.TaxonomyPart.Terms;

@terms.Count()

but this gives my only the count of taxonomy items, not the count of content items inside each taxonomy.

how can i display this?

도움이 되었습니까?

해결책

EDIT

Each term has the Count of ContentItems, is the Count value of TermPart.Count. Every time a content item is tagged with the term the TermsPartHandler refresh the count.

The TaxonomyItem template uses DisplayChildren, and for each Term it will render the template TaxonomyItemLink.

@*
   This shape is displayed for a TermPart when in a Taxonomy details page.

   Alternates:
   - TaxonomyItemLink__[HtmlClassifiedTaxonomyName]
   - TaxonomyItemLink__[HtmlClassifiedTaxonomyName]__[HtmlClassifiedTermName]
*@
@using Orchard.Taxonomies.Models
@{
   TermPart part = Model.ContentPart;
}

<span> This is the number of content items with this Term @part.Count </span>   

@Html.ItemDisplayLink(part)

That is the count of items for that Term, not the Taxonomy.

다른 팁

Simply resolve taxonomy service from TaxonomyItemLink.cshtml

var _taxonomyService = WorkContext.Resolve<Orchard.Taxonomies.Services.ITaxonomyService>();

And then for each terms from a taxonomy just count the ContentItems

@{
  var NumberOfContentItems = _taxonomyService.GetContentItems(part).Count(); 

}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top