cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SmartEdit extension with custom modals

Former Member
0 Kudos
900

I'm creating a custom smartedit extension that adds CSS classes to some components (e. g. paragraphs). The main goal is to allow the user select a style from a list within a pop-up window.

This behavior is already done by the "Edit" option in any perspective (basic or advanced).

However I would like to create or reuse the smartedit modals and include my own options.

Is this possible in SmartEdit? What services or modules should I use?

Thanks in advance.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello, to add more on this topic. You would need to add a property to the ParagraphComponentModel in cms2 extension add it a property named, for example, "style" of type String. After building and running you will see a new field of type input type='text' appearing. This is the default behaviour for String types. You now probably want it to be a dropdown instead and filled with your options.

see DropdownOptionsTypeAttributePopulator or UriComponentTypeAttributePopulator in cmsfacades

 <bean id="stylesTypeAttributePopulator" class="de.hybris.platform.cmsfacades.types.populator.DropdownOptionsTypeAttributePopulator">
     <property name="optionsList">
         <list>
             <value>style1</value>
             <value>style2</value>
             <value>style3</value>
             <value>style5</value>
         </list>
     </property>
 </bean>

add an entry to defaultCmsAttributePredicatePopulatorListMap with the key being your predicate and the value being the stylesTypeAttributePopulator

the predicate can trigger on the property name, its class, or the Paragraph class Smartedit comes with a set of ready to use predicates and you can create your own.

Documentation will help you with the details

Regards

Former Member
0 Kudos

Hello Mario, If you want to add a field or pull-down menu to a modal (such as the Content tab of the Component Editor), you should extend the CMS Structure API to support it. Here are some (hopefully) helpful links:

Hope this helps.