3

I am trying to make a file field editable in the Experience Editor. But neither @Html.Glass.Editable(field, f => f.File) nor the usage of an @Html.BeginEditFrame works. Is there a way with Glass Mapper for doing this?

0

2 Answers 2

4

Like Mark Cassidy said, no you can't do this with Glass.

However you have another option in the Experience Editor (although not specific to Glass), if you want to give users the ability to still edit the field that is of type "File Upload". You can add a custom experience editor button to the rendering that displays the file upload.

The first step is to create the button in the core here: /sitecore/content/Applications/WebEdit/Custom Experience Buttons. You would insert a new item from template. The template you would want to select is /sitecore/templates/System/WebEdit/Field Editor Button.

You should give the item a descriptive name. It can be only ever used with that specific rendering, or if you always use the same name for all file upload fields, you could make it very generic to use across renderings. You will be presented with the following fields to complete:

  • Header: Just the name of the Button
  • Icon: Specify an icon to represent the button
  • Fields: This is the most important part. You should specify the item name in a pipe separated list. Example in my system I created a field called "Upload" that is of type "File Upload", so i just specified "Upload" in this text box.
  • ToolTip: Just a friendly hover label for your button.

Example of my setup

That's it for the configuration. By using that item type, Sitecore out of the box handles all the heavy lifting of displaying the modal etc. So the next step is to assign this new button to your rendering. To do so, navigate back to the "Master" database and find your rendering in /sitecore/layout/Renderings although this could also apply to sublayouts. Click on the rendering you want to edit and find the field Experience Editor Buttons under the editor options section.

You should see the field you defined, plus some default buttons that are part of Sitecore OOTB. Select the button you created. You are all set to check out the experience editor. Navigate to a page that will have the rendering you just configured and open up that page in the experience edit. Click on the rendering and now you should see something like this:

Buttons specific to my rendering

The first button you see is the button you customized. You will of course see other buttons you can use to customize options related to your rendering. If you click on the button, then it'll automatically trigger a modal popup and display any fields you specified when you configured the button:

customize experience editor

This setup is perfect for scenarios where either there isn't a field renderer for a field you are needing the user to edit, but also in the scenario where you have linked fields where the Sitecore item just stores an id. You can allow the user to use a Content Editor style field instead.

2

No

Not with Glass Mapper, not using vanilla tools and APIs.

Looking at the official Sitecore Documentation for this (Edit content directly on the page) we learn that these are the fields are supported for inline editing (which is essentially what .Editable enables):

  • Simple text fields – this field can only contain simple text, such as single-line and multi-line text, dates, and links.
  • Rich Text fields – this field gives you more control over how the text appears on the webpage. You can edit a Rich Text field directly on the page or open the Rich Text Editor to get access to more formatting functionality.
  • Word fields – this field allows you to use Microsoft Word to edit the text. Depending on the configuration of your website, you can edit the Word field in Microsoft Word or directly on the page. If your website supports inline editing, all of the features of Microsoft Word are also available in the inline editing pane.
  • Image fields – a field that only contains images. In an image field, you can change the image, modify the image appearance, or remove the image directly on the page.

For more information, refer to the linked article.

Also, as mentioned in comments, more information available here:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.