1

I am currently trying to understand a bit more about how Orchard handles Lists of Custom Content Types and I have run into a bit of an issue.

I created a Content Type named Story, which has the following parts:

  • Body
  • Common
  • Containable
  • Route

I created a list that holds these items, and all I am attempting to do is style them in such a way:

Story Title
Story Description (Basically a truncated version of the body?)

However, I cannot seem to figure out how to do the following:

  1. Get the Title to actually appear (Currently all that appears is the body and a more link)
  2. Remove the "more" link (and change this to be the actual Title)

I have looked into changing the Placement.info, and have looked all over in an attempt to find where the "more" link is added in each of the items. Any help would be greatly appreciated.

Rion Williams
  • 74,820
  • 37
  • 200
  • 327

2 Answers2

3

I finally managed to figure it out - Thanks to the Designer Tools Module, which made it very simple to go look into what was going on behind the scenes during Page Generation.

Basically - all that was necessary to accomplish this was to make some minor changes to the Parts.Common.Body.Summary.cshtml file. (found via ../Core/Common/Views/)

Which initially resembles the following:

@{     

[~.ContentItem] contentItem = Model.ContentPart.ContentItem;
string bodyHtml = Model.Html.ToString();
var body = new HtmlString(Html.Excerpt(bodyHtml, 200).ToString()
               .Replace(Environment.NewLine,"</p>"+Environment.NewLine+"<p>")); 

}

<p>@body @Html.ItemDisplayLink(T("more").ToString(), contentItem)</p>

however by making a few changes (by using the Designer Tools) I change it into the following:

@{ 

[~.ContentItem] contentItem = Model.ContentPart.ContentItem;
string bodyHtml = Model.Html.ToString();
string title = Model.ContentPart.ContentItem.RoutePart.Title;
string summary = Html.Excerpt(bodyHtml, 100) + "...";

}

<div class='story'>
    <p>
    @Html.ItemDisplayLink(title, contentItem)
    </p>
    <summary>
    @summary
    </summary>
</div>

Although it could easily be shortened a bit - It does make the styling quite a big easier to handle. Anyways - I hope this helps :)

Rion Williams
  • 74,820
  • 37
  • 200
  • 327
2

Alternately you can use the placement.info file in your theme assign different fields to your Summary and Detail views. It's much simplier.

http://orchardproject.net/docs/Understanding-placement-info.ashx

But, I used the same method you did till I discovered the .info file as well. It works and gives you a good understanding of how the system works, but the placement.info file seems easier.

Also, you probably don't want to be editing the view files in Core. I think your meant to override views in your theme directory.

DanielEli
  • 3,393
  • 5
  • 29
  • 36
  • Right - I eventually read more with regards to overwriting and the use of Alternative Views, so I changed several things up a bit. I had looked at manipulating the Placement.info file several times, as I had made changes to it in other areas. I'll tinker with it a bit more, I was just looking for a simple way to completely restyle all of an area. Thanks though Daniel :) – Rion Williams Jul 21 '11 at 21:58