Orchard - How to show more fields of a content item in a summery view
Let's say I have a product to which I've added an image field called SmallImage.
When I show a list of products, I want the small image to be in the view. When I go to the list of divisions I get the default summary view, like so:
<article class="content-item @contentTypeClassName">
<header>
@Display(Model.Header)
@if (Model.Meta != null) {
<div class="metadata">
@Display(Model.Meta)
</div>
}
</header>
@Display(Model.Content)
@if(Model.Footer != null) {
<footer>
@Display(Model.Footer)
</footer>
}
</article>
How does @Display(Model.Content) generate the HTML?
Where is the .cshtml file I can put @Html.Image(Model.SmallImage) into?
EDIT
Ok, I found the property off the model: Model.ContentItem.Product.Small开发者_如何学PythonImage.FileName, so I just need to know where the template file is.
THX! Dan
Bonus Question: Using the designer tools in any list view. Go to Zone[Content].Content.List. Under Shape is says there are two alternate views. One is MyTheme/Views/List.Html. If you click on "create" it says The relative virtual path 'Orchard.Core.Shapes.CoreShapes::List' is not allowed here. Does that mean that there really isn't an alternate for this view?
I manually created the file that was giving me the error in the bonus question and this gets me the image. (List-url-products.cshtml)
<div>
@foreach(var item in Model)
{
<div>@item.Title.ToString()</div>
var division = item.ContentItem.Division;
var smallImage = (Contrib.ImageField.Fields.ImageField) division.ListImage;
if(smallImage.FileName != null)
{
<div>@Html.Image(smallImage.FileName, null, new { Width=smallImage.Width, Height=smallImage.Height }) </div>
}
}
</div>
精彩评论