I have a CQ5 component with a delete button in the author mode's edit view. Now there are two possible ways to include this component in a page:
How do I configure CQ5.5 to only show the delete button in the editbar when the component is shown within a parsys. When the component is statically included via a cq:include the delete button should not be shown as it's not possible to delete the component from the page in that case.
Any ideas?
I only found the following CQ5 documentation how to generally remove the delete button from the editbar: http://dev.day.com/docs/en/cq/5-5/developing/components/edit_config.html#cq:actions
Also the delete button is correctly shown and hidden if I do NOT use the layout editbar :/
There is no OOTB way to dynamically configure the editConfig depending on context, so the easiest solution would be to create a new component extending the original one which would override only the cq:editConfig
node. So you end up with two flavours of the same component: one for the parsys, and another for static include, but without any code duplication, since the other one would be a 'shallow' override.
Copy the original component to a new one, remove 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 original component has a resourceType of /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, then you will need to migrate the resource type for the component with the 'new' behaviour. This could be done (1) manually in CRXDELite, (2) using the Bulk Editor tool, or (3) via the Resource Type Updater from the ACS AEM Tools.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With