3

Using sc8.0 with MVC.
There is a rendering to render banner items. Each banner item has a checkbox field "Is Featured". I would like to give the author to use the checkbox field in experience editor.

Below is something I tried, following an online article. I change the option in the dropdown and click on Save. It shows the red banner under menu - an error occurred. But there are no logs in console or in the data folder.

@if (isPageEditorEditing)
{
  <div>                                                    
    <select onchange="Sitecore.WebEdit.setFieldValue('@myitem.Uri', '@Fields.IsFeatured.ToShortID()', this.options[this.selectedIndex].value);">
     <option value="1">Yes</option>
     <option value="0">No</option>
    </select>
  </div>
 }
3

Since there is one rendering for many items you can almost follow Amit's answer but you will need to use an edit frame. Glass has a method that helps start an edit frame in mvc. For more info about incorporating that see the following link: https://visionsincode.wordpress.com/2015/01/08/how-to-use-editframe-in-sitecore-mvc/

You will have to pass the edit frame helper the current item that will have the checkbox to change and the id or path to your custom experience button. My example item: https://www.screencast.com/t/y3WnJod3

@foreach(var bannerItem in myBannerList)
{

    using (Html.BeginEditFrame(bannerItem, "{FDE5A219-C691-4978-B9D2-939E98582626}")
    {
        ...banner html here...
    }
}

Your id will be different and should be maintained in a constants file instead of as a raw unnamed string but this should demonstrate the idea.

There is another more elegant option too but it takes a little more work and I have not actually tried it myself. You can create an Edit Frame Small Button and give it a command. You would then assign this button to the edit frame instead of the one shown earlier. This type of button takes a command which you will want to insert into the command section of Sitecore's configuration through a patch config. It would be worth while to make the code the command points to somewhat generic in that it should read in a parameter for the name/id of the field that it will try to toggle. This method allows a user to simply click the button that appears on the edit frame and toggle the checkbox. The other way opens a modal which displays the checkbox field.

1

I would prefer adding a custom experience button in the Core Database. Once the button is created we can show this button in a floating toolbar on the component. Also, in Sitecore we need to mark this as editable.

Please check the link below on how to add custom fields to enhance experience editor for the editors.

https://community.sitecore.net/technical_blogs/b/maximizing_usability/posts/enhancing-the-page-editor-experience-with-custom-experience-buttons

http://www.nonlinearcreations.com/Digital/how-we-think/articles/2016/03/Sitecore-8-and-8-1-How-to-add-a-Field-Editor-Button-to-a-component-in-Experience-Editor-Mode.aspx

Hope it helps.

  • 1
    Can you elaborate on the links you provided - otherwise the answer might get flagged as link-only... – Gatogordo Apr 17 '17 at 17:27
  • @Amit. I see that you have suggested the use of Custom Experience buttons. These buttons are associated with a rendering right. I'm my case, there is a rendering which renders multiple banner items each having a checkbox field. Do you still think it will work, because it did not, for me. Should it be done in some other way? – Qwerty Apr 18 '17 at 5:38
  • @Qwerty - i still think that the approach should work. It might not provide you with a perfect experience editor view option, but it can surely open a dialog box for you to select/deselect your banner items to display. – Amit Gaurav Apr 18 '17 at 8:30
  • @Amit. you will only be able to edit the parent rendering with the customer experience button. Not edit each child banner as he has suggested. I was going to suggest using ItemRendering and edit each item with a custom experience button. But even in Item Rendering, it does not show the toolbar. And it makes sense since the rendering is not in the page. It is added at run time. Html.BeginEditFrame is the better option. I wrote a whole solution trying to prove you were right, but I failed. github.com/dnstommy/Example-Nested-Renderings – Chris Auer Jun 14 '17 at 2:23

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.