Baldwin
Baldwin

Reputation: 71

How to hide label part of customized field?

As title mentioned, I just would like to display the main part of special field without any label.

For example, The new "Thumbnail" field added into "Blog Post", in the summary view list, I want to show the thumbnail token combined with some summary in the right.

The thumbnail token only included the image tag like that:

<img src=".../sample" alt="blog post thumbnail"/>

So is there any elegant solution for that?

Issue about label

BTW, I know some thing to remove the metadata and title of this field by adding options in placement.info file like that

<Match DisplayType="Media">
    <Place Parts_Title="-"
           Parts_Common_Metadata="-" />
</Match>

So now the issue is how to hide label part?

Thanks a lot.

Upvotes: 1

Views: 476

Answers (2)

Baldwin
Baldwin

Reputation: 71

Finally I found out the template called "MediaLibraryPicker.cshtml", which is responsible for the display layout of media.

It is placed in the folder below:

$ROOT/Modules/Orchard.MediaLibrary/Views/Fields

To override it, just copy it into the same folder of your current theme, such as:

$ROOT/Themes/YOURTHME/Views/Fields

Then open it and modify it like what you want:

@using Orchard.ContentManagement
@using Orchard.MediaLibrary.Fields
@using Orchard.Utility.Extensions;

@{
var field = (MediaLibraryPickerField) Model.ContentField;
string name = field.DisplayName;
var contents = field.MediaParts;
}
<section class="media-library-picker-field [email protected]()">
    @foreach(var content in contents) {
        @Display(BuildDisplay(content, "Raw"))
    }
</section>

Hope it helps for others if you have the same issue :)

Upvotes: 1

Bertrand Le Roy
Bertrand Le Roy

Reputation: 17814

Override the template in your theme, don't include the markup for the field's name in there.

Upvotes: 0

Related Questions