Filip
Filip

Reputation: 1864

Orchard does not shows Model properties in custom views

after couple of hours of trying I am absolutely clueless about how customize the way Orchard displays blog posts in lists and individual view.

IEnumerable<object> blogPosts =
        Model.ContentItems.ContentItems;

 <ul class="content-items">
    @foreach (dynamic post in blogPosts) {
        string title = post.Title;     
        ContentItem item = post.ContentItem;
        <li class="content-item-summary">
            @Html.ItemDisplayLink(title, item)


        </li>
                 }
    </ul>

This is my code for displaying blog posts in list. I am only able to show title surrounded with hyperlink. I cannot figure out, how can I access Body text, Tags or even image added as field. @Model.Body.Text and various other does not work.

I must be doing something very wrong, because it cannot be that hard, can it? I previously created some sites on Umbraco and was able to accomplish this very easily.

I want my list to contain for every post title (done), then excerpt from body and image from Media Library Picker Field. It shows everything automatically when I open individual articles.

I watched Pluralsigh fundamentals, read documentation, experimented with shape tracking...

Thanks for any help or pointing in the right direction.

Upvotes: 0

Views: 82

Answers (1)

devqon
devqon

Reputation: 13997

You can access the other parts like so:

ContentItem item = post.ContentItem;
var bodyText = item.As<BodyPart>().Text;

Upvotes: 1

Related Questions