List Shape

The whole displayed list has its own shape, named Taxonomy.List. The original one can be found under /Contrib.Taxonomies/Views/Items/Taxonomy.List.cshtml.
This shape exposes a few alternates like these ones:
  • Taxonomy.List.TaxonomySlug.cshtml
  • Taxonomy.List.TaxonomySlug-TermSlug.cshtml
  • Taxonomy.List.TermId.cshtml

For instance, if a taxonomy is named Categories and the list for the tern France is displayed, France being a sub term of World, then the following alternates are availabe:
  • Taxonomy.List.Categories.cshtml
  • Taxonomy.List.Categories-World.cshtml
  • Taxonomy.List.Categories-World-France.cshtml
  • Taxonomy.List.12.cshtml

While rendering the shape, those properties are available:
  • Model.Term
  • Model.Taxonomy
  • Model.List

The minimal requirement is to call @Display(Model.List) to render each content item associated to the currently displayed term.

Content Item Shape

When the list is displayed, each child shape will also have a set of alternate which can be used to be rendered based on the currently displayed term. Those available shapes are:
  • Taxonomy.Content.TaxonomySlug.cshtml
  • Taxonomy.Content.ContentType.TaxonomySlug.cshtml
  • Taxonomy.Content.TaxonomySlug-TermSlug.cshtml
  • Taxonomy.Content.ContentType.TaxonomySlug-TermSlug.cshtml
  • Taxonomy.List.ContentType-TermId.cshtml

Here are the generated ones for the same example as previously:
  • Taxonomy.Content.Categories.cshtml
  • Taxonomy.Content.BlogPost-Categories.cshtml
  • Taxonomy.Content.Categories-World.cshtml
  • Taxonomy.Content.BlogPost-Categories-World.cshtml
  • Taxonomy.Content.Categories-World-France.cshtml
  • Taxonomy.Content.BlogPost-Categories-World-France.cshtml
  • Taxonomy.Content.23.cshtml
  • Taxonomy.Content.BlogPost-23.cshtml

Practical Usage

In case you want to display a specific set of elements based on a term, it's convenient to create a menu item for each of those terms. For instance, in a News Website, the main menu displays the topics for the articles, like World, Business, Culture, Technology. Let's say that those elements are reprensented by terms in a taxonomy named Topics, then you might want to display the items for Technology with a specific template, and all the others with another template.

The solution is to create a file named Taxonomy.List.Topics.cshtml which will be used to display any Topic list of items, and another one named Taxonomy.List.Categories-Technology.cshtml, specific for the content items displayed when querying the content items associated to Technology.

Last edited Dec 26, 2010 at 4:11 PM by sebastienros, version 2


No comments yet.