Hide the "Delete" button in the edit panel depending on Parsys

I have a CQ5 component with a delete button in author mode editing mode. Now there are two possible ways to include this component on the page:

  • Statically via cq: include tag
  • Dynamically using the parsys component

How to configure CQ5.5 only to display the delete button in the edit panel when the component is displayed in the parsys section. When a component is statically enabled via cq: include, the delete button should not be displayed, since in this case it is impossible to remove the component from the page.

Any ideas?

I found only the following CQ5 documentation, how to remove the delete button from the edit panel: http://dev.day.com/docs/en/cq/5-5/developing/components/edit_config.html#cq:actions

Also the delete button is displayed correctly and hidden if I DO NOT use the layout editing panel: /

+6
source share
3 answers

There is no OOTB way to dynamically configure editConfig depending on the context, so the easiest solution would be to create a new component that extends the original, which will only cover cq:editConfig node. Thus, you get two variants of the same component: one for parsys, the other for static, but without duplication of code, since the other will be a “minor” override.

Copy the source component to the new one, delete all the files in the new component except .content.xml and _cq_editConfig.xml , in which you need to remove DELETE from cq:actions .

For example, if your source component has resourceType /apps/mysite/myoriginalteaser , then in the new component you should set in .content.xml :

 .content.xml: <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="cq:Component" sling:resourceSuperType="mysite/myoriginalteaser"/> ^^^^^^^^^^^^^^^^^^^^^^^ 
 _cq_editConfig.xml: <jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="cq:EditConfig" cq:dialogMode="floating" cq:actions="[text:My Fixed Teaser,-,EDIT]" cq:layout="editbar"> 

NB . If you already have production content with the original resource type, you will need to transfer the resource type for the component with the “new” behavior. This can be done manually (1) manually in CRXDELite, (2) using the Bulk Editor tool, or (3) using the Resource Type Updater from ACS AEM Tools .

+3
source

You can use ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE for this. Check Install the CQ5 component in editable or not editable . You must set it before turning on static, and then remove it immediately afterwards so that the delete button can be used in parsys. But then you will also lose the edit button, which may be undesirable.

Another option is to create a second component that uses the first as its super type (sling: resourceSuperType). All functionality (dialog, JSP) is inherited, with the exception of the editing configuration. You changed the editing settings for the second component and used it to enable static, while the 1st component would remain available in Sidekick for use in parsys.

0
source

Shawn's solution completely removes the edit panel (albeit in a crazy hacker way), but many of us still want to edit the component without the delete option.

CQ has become a very common topic that things are simply impossible, so we spend so much time looking for crazy hacks and workarounds until we find the “least terrible solution we can find.” Many configurations are very poorly defined. This is one of them and is considered one of the most powerful features of AEM (editing panel). The other flagship function (parsys) is also broken largely because they built all / etc / projects just to determine what types of components can live in parsys, without providing any clean way to do nested parsys and force type detection containers. Honestly, I could talk for hours about all the crazy ways that CQ implemented, but I already said too much.

My solution: copy the component, paste it, slightly change the name, remove the delete option from the edit panel. Ruthlessly, how the hell? Yes. They will go out of sync, no matter how clearly you communicate and document the code. But you have to ask yourself: is it worse than writing your own sling filter filter ? Um ... no it's not :)

0
source

All Articles