4

I've created my own custom experience button to edit some responsive images for a logo in my header and I added the button to the rendering. It works as expected and I am not having any problems with it.

However, I would like to move the button to an edit frame using Glass Mapper's BeginEditFrame so that the content manager can just click on some placeholder text to access the custom button.

I'm trying to use the edit frame with this signature - BeginEditFrame(string buttons, string dataSource, string title).

My code is as follows:

using (BeginEditFrame("{CDA69877-442C-47CC-87D3-E1D2BF61E5B8}", "{6F455DBC-29FE-40FC-9803-0A738677EC04}", "Logo Images"))
{
    <p>Click here to edit the logo.</p>
}

The first Guid represents the ID of my custom button. The second Guid represents the datasource item containing my logo images.

I also tried using the filepaths instead of Guids but got the same results.

In case it helps, my button is found at /sitecore/content/Applications/WebEdit/Custom Experience Buttons/Responsive Images

And my datasource item is at /sitecore/content/siteroot/Data/Headers/Header

I don't get any errors with this code, but the edit frame that pops up does not have anything useful. I've pasted it below.

Edit Frame Pop-up

  1. Am I correct in using my custom button filepath/Guid for the buttons parameter? (Edit: I just figured this part out. I needed to use the filepath/Guid for the folder containing the buttons and not the filepath/Guid for the button item itself.)

  2. And is the datasource item that holds the logos in question the datasource parameter that the method signature is asking for?

2 Answers 2

1

I figured it out.

  1. For the buttons parameter, I needed to use the filepath/Guid for the folder continaing the buttons I want to be displayed on the edit frame.

  2. This worked when I used the Guid of the datasource item containing my logo images, which is what I thought it should be. I'm not sure why it didn't work initially.

0

If you are using Glass Mapper 5 then you can apply EditFrame using below code:

@using (Html.Glass().BeginEditFrame(Model.HeroBanner, "Edit Banner", m => m.BannerImage,
    m => m.BannerNavigation, m => m.ShowSameMessage, m => m.HideSection))
{
    <div class="background" style="@(Model.HeroBanner.BannerImage != null ? "background-image: url(" + Model.HeroBanner.BannerImage.Src + ")" : "")">
        @if (Model.HeroBanner.BannerNavigation)
        {
            <div class="heading">
                <div class="@(Model.HeroBanner.HeaderStyle != null ? Model.HeroBanner.HeaderStyle.CssClass : "heading-2")">
                    @Html.Glass().Editable(Model.HeroBanner, m => m.BannerTitle)
                </div>
            </div>
        }
        if (!Model.HeroBanner.HideSection)
        {
        <div class="section">
        </div>
        }
    </div>
}

Here Mode.HeroBanner is Model Class and BannerImage, BannerNavigation, ShowSameMesage, and HideSection are the Class properties.

It will allow you to edit all the above properties to edit in EditFrame, you don't need to create any Custom Experience Button.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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