Add custom page editor buttons to a FieldRenderer's edit frame

502 Views Asked by At

If I have a <sc:FieldRenderer> or related control in a sublayout, and I wrap it in a <sc:Link> control, the FieldRenderer will have an additional button to edit the link field, rather than a second wrapping EditFrame.

Is it possible for other buttons to be added to the built-in field renderer controls in the same manner rather than using an <sc:EditFrame> control?

For example, if I used the following markup:

Good:
<div class="example">
    <sc:Text runat="server" ID="Text" Field="Text" />
</div>

Is it possible to add custom buttons to the edit frame shown in the page editor for the Text control, without needing to rely on an EditFrame control?

Bad:
<div class="example">
    <sc:EditFrame runat="server" ID="Edit">
        <sc:Text runat="server" ID="Text" Field="Text" />
    </sc:EditFrame>
</div>
2

There are 2 best solutions below

1
On

Yes this is possible. First, find the field item itself in the CMS. For example you're field is called Text, so pretend your field definition item is located at /sitecore/templates/user defined/My Sample Template/Sample Section/Text. On that field definition item scroll down to the Page Editor Buttons field and you can add any WebEdit buttons to show in the Page Editor selection of that field. Now at this point you may actually need to define a custom WebEdit button.

1
On

Is it possible for other buttons to be added to the built-in field renderer controls in the same manner rather than using an control?

No. sc:FieldRenderer is a readonly control which serves any text based on its Field name.. its not possible to add additional controls to it. I usually use a .net Literal & keep adding plain HTML coming from sitecore dynamically from code behind