How can I render a Part in a template?

Topics: Customizing Orchard, Writing themes
Dec 25, 2014 at 3:28 AM
Edited Dec 25, 2014 at 3:31 AM
There are many parts in a page. For examples, TitlePart, CommentsPart, TagsPart.
My question is, how can I render a part?

My content type is News, I can show the TitlePart use:
But how can I render the CommentsPart / TagsPart?
I think i can use:
but it cause a stack overflow error.

anyhelp is appreciate.
Dec 25, 2014 at 5:56 AM
you can builddisplay for content item, but not content part.
but there're workarounds , such as :
  • create an alternate for the content item that display only your part.
  • create a custom display type and configure the to display only your part
  • display the same shape as the one used in your driver.
Dec 27, 2014 at 9:30 PM
Dec 27, 2014 at 9:51 PM
Also, the Orchard.Layouts module provides a service for just that purpose: rendering individual parts and fields:
  • IContentPartDisplay
  • IContentFieldDisplay