I've been struggling with placing specific parts of a Content item in a view. My question is how do I define a cshtml
view/shape for a content item for which I can place each part where I want. Consider the following content item:
item
- Text field
- Media field
And the following
<div class="my text">
@Model.TextField1
<div class="media-item">
@Model.MediaField
</div>
</div>
<p> Some text or stuf here or anyehere</p>
I can't seem to find any example of that. It should be a basic view for a content with assigned objects to each part of that content but I am finding it impossible to implement (btw I don't want to use layouts).
If you have a working alternate, say Content-MyContentType.cshtml, you can do the following:
<div class="my text">
@Display(Model.TextFields)
<div class="media-item">
@Display(Model.Media)
</div>
</div>
<p> Some text or stuf here or anyehere</p>
And then you can do in your placement.info:
<Match ContentType="MyContentType">
<Place Fields_Common_Text="TextFields" />
<Place Fields_MediaLibraryPicker="Media" />
</Match>
Note
I am not sure what type of fields your textfields and/or your media is, so you might need to change the Fields_Common_Text and Fields_MediaLibraryPicker to match the types of your fields.