jcomet
jcomet

Reputation: 227

How to create template for content part created in admin in an orchard site

I am new with Orchard and can not seem to get past this problem.

Goal

  1. to be able to specify two text values on each page and show those in a styled DIV if they are not blank.

Procedure

  1. I created a new content part in Orchard's admin named "InnerPageTitleArea"
  2. I added two fields to this part: IpTitle (Text Field) and IpSubtitle (Text Field)
  3. I added this part to the Page content type
  4. Those textboxes show when editing a page, and I filled them in on several pages
  5. Those values show on pages they were entered on (all good so far)

The problem:

  1. I want to provide a template for the InnerPageTitleArea, but all attempts have failed.
  2. When using shape tracing, there are no alternates referencing my part alone
  3. All alternates begin with "Fields" i.e. ~/Themes/MyTheme/Views/Fields.Common.Text-InnerPageTitleArea.cshtml.
  4. If I use one of those field alternates, my template is repeated twice - once for each field
  5. If I use a field-specific template, i.e. ~/Themes/MyTheme/Views/Fields.Common.Text-InnerPageTitleArea-IpTitle.cshtml I can actually get at both values, but then the other value (IpSubtitle) still displays as plain text. I could probably remedy that with Placement.info, but I suspect that I am just lacking some fundamental understand of Orchard.

What to do?

Upvotes: 1

Views: 698

Answers (1)

Bertrand Le Roy
Bertrand Le Roy

Reputation: 17814

Your part never renders anything because it doesn't have a driver that would create a shape. The only shapes that are getting out of that part are the shapes for each of the fields. The simplest way to get what you want is to create one alternate for each of the fields. Would that work?

Upvotes: 1

Related Questions