4

When adding a component to a placeholder, how would I go about setting default values for custom styles in the rendering parameters so that certain styles are enabled automatically for the user when they creating a component in Experience Editor?

i.e. in the Styling section of the component properties modal, set a custom CSS class to a default value:

enter image description here

1
  • I think that a more concrete example would make the problem easier to be understandable. What is the component you are using? And what would be the CSS value you want to add and on which field that value should go? Feb 18, 2019 at 23:28

1 Answer 1

5

Standard Values on rendering

The only one out of the box solution is doing it via Standard Values on rendering parameters.

Pro:

  • no code
  • easy

Cons:

  • default values defined globally per rendering parameters

ExecutePageEditorAction

Add additional processor to ExecutePageEditorAction pipeline.

Take a look at Sitecore.XA.Feature.PageStructure.Pipelines.ExecutePageEditorAction.FillColumnSpliterDefaultGridValues as an example where default grid values are assigned to the splitter columns.

Pro:

  • fast

Cons:

  • executed only in EE, so if rendering will be added via CE, a code will not be invoked

PresentationProcessing

Add additional processor to PresentationProcessing pipeline.

Take a look at Sitecore.XA.Foundation.Presentation.Pipelines.PresentationProcessing.SetDefaultParameters.

Be careful. This pipeline is launched during save, not like ExecutePageEditorAction only during drag&drop in EE (AddRendering action)

Pro:

  • executed both for EE and CE

Cons:

  • potentially might cause problems with performance if the implementation will be heavy

Summary

If you can live with fact that editors are able to add rendering with default CSS classes in EE only I would recommend you ExecutePageEditorAction

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.