0

I'm extending the SXA Accordion component to add a header to the accordion. Ok, derive a template from Accordion template, add the Page Component to the presentation details for the standard values, create a new controller, model, repository and view, all based on the Accordion component.

        @if (Model.Rendering.DataSourceItem != null)
        {
            if (Model.Title == null)
            {
                using (Html.Sxa().BeginEditFrame(Html.Sitecore().CurrentRendering.DataSource, "Header Empty", Model.IsControlEditable))
                {
                    <div class="accordion-header">
                    [Heading is empty]
                    </div>
                }
            }
            else
            {
                using (Html.Sxa().BeginEditFrame(Model.Title.ID, "Header", Model.IsControlEditable))
                {
                    var titleKey = string.Format("{0}-{1}", titleBaseKey, Model.Id);
                    <div class="accordion-header">
                        @Html.Sitecore().Placeholder(titleKey)
                    </div>
                }
            }
        }

In the new template, I added a Title field (rich text). The Title field in the model is just the rendering DataSourceItem. How do I get the Title field of the new template to show up as a variant in the rendering parameters for the Page Content? Remember the new template has the Accordion as the base template.

3
  • I don't get the question.. why do you need "Page Content" if your title field is in the datasource template?
    – Gatogordo
    Sep 17, 2020 at 16:12
  • I a using the Page Content to allow a the rich text editor to be used to edit content. Is there some other way I should be doing this? Sep 17, 2020 at 17:47
  • I can change this to use the rich text for the presentation details, but it still won't let me choose the field name to use for the variant. Sep 17, 2020 at 20:52

1 Answer 1

1

I found that adding the template to the experienceAccelerator/getVariants/allowedTemplates in a configuration file seemed to make this work.

Your Answer

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

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