Edit ContentType Media Picker Field

Topics: Administration
Sep 25, 2012 at 3:22 PM

Hi,

I add two fields Media Picker Field.

The first one has the purpose to display a picture from the image Gallery

The second has the purpose to display a picture from a url website.

I use Visual Studio to build and start the website.

I notice for the fist one by using developper tool from chrome I have displayed

Picture 1 : ~/Media/Default/ImageGalleries/Ebook/lesgrottesdekalteBig.jpg

With a source html

span class="value" shape-id="10">~/Media/Default/ImageGalleries/Ebook/lesgrottesdekalteBig.jpg</span>

And for the Picture 2

I see nothing exept Picture 2

<span class="name" shape-id="11">Picture2:</span>

The two are included in a <p> with the class media-picker-field media-picher-field-picture-

In the administration part I can see for 

Picture 1 : ~/Media/Default/ImageGalleries/Ebook/lesgrottesdekalteBig.jpg

Picture 2 : http://img.clubic.com/0140000005424773-photo-gigabyte-p2542g.jpg

Do you have any idea? (I am trying to use iis instead casini from visual studio 2010)

Best regards,

Alexandre

Sep 25, 2012 at 4:06 PM

I think I need to investigate the two links below to understand it

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

http://docs.orchardproject.net/Documentation/Understanding-placement-info

So I continu to search :)

 

Coordinator
Sep 25, 2012 at 4:41 PM

Override the template in your theme. For example, Views/Fields/MediaPicker-NameOfYourField.cshtml:

@using Orchard.Utility.Extensions;
@{
    string name = Model.ContentField.Name;
    string url = Model.ContentField.Url;
}
@if (!String.IsNullOrWhiteSpace(url)) {
    <a href="@Href(url)" target="_blank"><img src="@Href(url)" alt="@Model.ContentField.AlternateText" class="media-picker-field media-picker-field-@name.HtmlClassify()"/></a>
}
@* Other available properties

    Alternate Text: @Model.ContentField.AlternateText
    Class: @Model.ContentField.Class
    Style: @Model.ContentField.Style
    Alignment @Model.ContentField.Alignment
    Width: @Model.ContentField.Width
    Height: @Model.ContentField.Height
*@

Sep 25, 2012 at 7:41 PM

Hi,

Thank you, I modify the theme according to your recommandations.

In the link Placement-Info, I notice "A theme author can then provide a Parts/Tags.ShowTags.BlogPost.cshtml file that customizes the display of tags for blog posts."

So If I understand, each time I would like to customize a display from a fields provided from a content Type I need to use the Views/Fields/NameOfContentType-NameOfYourField.cshtml Is-it right? 

I really need to go further in the knowledge. Sorry but I am just beginning :)

Is there any documentation or link related to your proposal, I dont find anything in the previous links indicated the MediaPicker-NameOfYourField.cshtml (from previous post).

Best regards,

Alexandre

Coordinator
Sep 25, 2012 at 11:23 PM

Almost, except it's Views/Fields/NameOfFieldShape-NameOfField.cshtml. I think this is the topic you're looking for: http://docs.orchardproject.net/Documentation/Alternates

Sep 26, 2012 at 4:01 AM
bertrandleroy wrote:

Almost, except it's Views/Fields/NameOfFieldShape-NameOfField.cshtml. I think this is the topic you're looking for: http://docs.orchardproject.net/Documentation/Alternates

I recommend enabling shapetracing module to get additional experience with alternates.  It will create a great popup at the bottom which will show you alternates available for your widget/content or single fields.  You'll also want to understand the placement.info files which can help you figure out where the fields will display in your content item.

Sep 26, 2012 at 7:50 AM

Hi,

thank you corecomps/

I use shape tracing module and I understand how bertandleroy found a sample of code.

Effectively, in http://docs.orchardproject.fr/Documentation/Customizing-Orchard-using-Designer-Helper-Tools, when I click on Template I found a sample of code related to ~/Modules/Orchard.Fields/Views/Fields/MediaPicker.cshtml.

Thanks bertrandleroy, http://docs.orchardproject.net/Documentation/Alternates it answered to my question.

Best regards,

Alexandre