Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8668165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:08:45+00:00 2026-06-12T18:08:45+00:00

This sounds like a (very) silly question but I just can’t find a way

  • 0

This sounds like a (very) silly question but I just can’t find a way to access a text field I’ve just added to a content type in Orchard. I know how to access the field when it is added to a content part, but not when it is added directly to the content type itself.

The content type is called Product, it is containable and is being shown in a list. I’ve added the ordinary parts, plus two custom fields: a MediaPicker field named “Image” and a Text field with HTML flavor named “About”. The code I’m using to render the list which contains it is the following:

@using Orchard.DisplayManagement.Shapes;
@{
    var list = Model.List;
    var items = list.Items;
    var count = items.Count;
    var listTag = Tag(list, "ul");
    listTag.AddCssClass("historia");
    var index = 0;
}

<div class="produtos">
    @foreach (var item in items)
    {
        var itemTag = Tag(item, "div");
        itemTag.AddCssClass("item-" + index);
        @itemTag.StartElement;
        <h3>@item.ContentItem.TitlePart.Title</h3>
        <img src="@Href(item.Image.Url)" 
            class="@item.Image.Class"
            alt="@item.Image.AlternateText" 
            width="@item.Image.Width" 
            height="@item.Image.Height" 
            style="@item.Image.Style" />
        <p>@item.About.Text</p>
        @itemTag.EndElement;
        ++index;
    }
</div>
@Display(Model.List)
@Display(Model.Pager)

The problem is that @item.Image does not yeilds the Image field, nor does @item.About yields the “About” text field. I don’t even know if a Text field has a .Text property to access its value, after all it can have HTML flavor… I don’t even know where to look in the source code to help me finding out how this is done!

I’ve tried some different approaches like @item.ContentFields.About.Text or @item.ContentField.About.Text, @item.Fields[0], @item.ContentItem.About.Text, @item.ContentItem.ContentFields.About.Text (the last two throws an exception telling me that ContentItem doesn’t have those fields…)

I know that if I had added the fields to a content part and this part to the content type I could have done this: @item.ContentItem.TheNameOfTheContentPart.Image.Url …

I’m becoming more and more frustrated as I can’t figure out how to do the simplest things in Orchard. I need that Eureka moment that will make me able to know where to look at in the source code to find answers to these kind of questions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:08:46+00:00Added an answer on June 12, 2026 at 6:08 pm

    A field is always under a part. It’s just that if you add the field from the admin, a part with the same name as the type will be created automatically for you.

    http://orchard.codeplex.com/discussions/396280

    You can’t add a field to a content type, you always add it to a content part. It’s just that if that part has the same name as the type, nice magical things happen.

    http://orchard.codeplex.com/discussions/397426

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may sounds like a stupid question but can't find anything on google, probably
I know this sounds like a broad question but I can narrow it down
sounds like very easy question but very often I am confused by this. Please
this sounds like a really simple question but could easily have a very complicated
This may sound like a very generic question but here it goes. I have
This sounds like a really simple question, but I am new to PHP. If
I know this sounds like a dumb question but I need to ask this.
Sorry if this sounds like a very basic question, it is my first time
This sounds like a stupid question, but thought I would post anyway... I am
I know this sounds like something I can google, but the truth is that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.