Remove field from part view

Topics: Customizing Orchard, General
Jul 2, 2013 at 8:03 AM
(this is loosely based on the Movies module)

So I have Halo (content item), which is a Product (content type) made of a Product (content part) which has a numeric field SKU.

My part view looks like this:
    <p>Product Code: @Model.ProductPart.ProductCode</p>
    <p>Description: @Model.ProductPart.Description</p>
    <p>SKU: @Model.ProductPart.ProductPart.SKU.Value</p>
    <p>Image Path: @Model.ProductPart.Image</p>
    <p>Notes: @Model.ProductPart.Notes</p>
    <p>Price: @String.Format("{0:c}", Model.ProductPart.Price)</p>
Which displays just fine, except the SKU is repeated underneath. How can I remove that?

On a related note, my editor template looks basically like:
@model CV.Prototype.ViewModels.ProductEditViewModel

<fieldset>
    <legend>@T("Details")</legend>
    @Html.LabelFor(m => m.ProductCode, T("Product Code"))
    @Html.TextBoxFor(m => m.ProductCode)
    @Html.LabelFor(m => m.Description, T("Description"))
    @Html.TextBoxFor(m => m.Description)
    @Html.LabelFor(m => m.Image, T("Image"))
    @Html.TextBoxFor(m => m.Image)
    @Html.LabelFor(m => m.Notes, T("Notes"))
    @Html.TextBoxFor(m => m.Notes)
    @Html.LabelFor(m => m.Price, T("Price"))
    @Html.EditorFor(m => m.Price)

</fieldset>
With the view model looking like:
    public class ProductEditViewModel
        {
            public string ProductCode { get; set; }
            public string Description { get; set; }
            public string Image { get; set; }
            public string Notes { get; set; }
            public decimal Price { get; set; }
    }
...and the SKU field always appears on top! What's the correct way to move that somewhere else in my Product view?
Coordinator
Jul 2, 2013 at 9:11 AM
Use shape tracing to view what shapes are being displayed, then use placement to hide what you need to hide.
Jul 3, 2013 at 12:28 AM
OK, I've tried a few different ways with no luck. The shape is "Fields_Numeric" and according to the doco I should be able to do something like this:
<Place Parts_Product="Content:4" Fields_Numeric-Sku="-" />
Or maybe this:
  <Place Parts_Product="Content:4" Fields_Numeric="-" />
Or this:
  <Place Parts_Product="Content:4" />
  <Place Fields_Numeric="-" />
But this has no effect on hiding the second instance of SKU.

According this blog it is not possibly without a bit of a hack:
http://sadomovalex.blogspot.com.au/2012/10/hide-content-type-fields-in-orchard-cms.html

Can you please advise? Thanks!
Coordinator
Jul 3, 2013 at 9:54 AM
That blog post in misinformed. If you got the shape right, and if the field driver has been properly written, placement will work, as explained here: http://docs.orchardproject.net/Documentation/Understanding-placement-info#"Place"Element
Jul 4, 2013 at 12:46 AM
I find this very confusing. In the end I edited the Placement.info for Orchard.Fields, removing <Place Fields_Numeric="Content:after"/>, and now it works as expected. Shouldn't the Placement.info in my module take precedence instead of the default?
Jul 4, 2013 at 4:50 AM
Oh I think I see, this might be a bug.

My SKU field was attached to a Content PART as opposed to a Content TYPE. When I attach it to the type it works just fine.
Developer
Jul 4, 2013 at 10:16 AM
BenPower wrote:
Shouldn't the Placement.info in my module take precedence instead of the default?
No, Placement.info in themes take precedence over Placement.info of a module.
If you do want to have your module's Placement.info file take precedence over the one from another module, you need to add that module as a dependency.