January 3, 2021
Estimated Post Reading Time ~

Add a button in site console's action toolbar to open pages in disabled mode

In the Author instance, sometimes we need to check pages in disabled mode to debug HTML/or to see pages how they will look in the publisher or other than edit, preview, design mode. AEM provides the way how to check pages in disabled mode, following are the ways -

1. Add wcmmode=disabled querystring in the page URL e.g.
http://localhost:4502/content/mfHTL63/en/demo1.html?wcmmode=disabled
2. Open a page as edit e.g. http://localhost:4502/editor.html/content/mfHTL63/en/demo1.html and then click on the page information button, it will show popover menu from there click on 'View as Published', a page will be opened in new tab with the disabled mode.


But if you are using the 'View as Published' option frequently then you can add a button in the site console to view page(s) in a disabled mode in one click.

Follow below step to add a new button/option :
overlay /libs/wcm/core/content/sites/jcr:content/actions/selection using Resource Merger (Overlay Node option from CRXDE).

CRXDE to overlay nodes

Create a node i.e 'view' and 'data' node child of 'view' node, as below screenshot
overlayed selection and view & data node

add the following properties to view and data nodes

<view
granite:rel="cq-siteadmin-admin-actions-edit-activator"
granite:title="View as Published"
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/collection/action"
action="cq.wcm.open"
activeSelectionCount="multiple"
icon="devicePreview"
target=".cq-siteadmin-admin-childpages"
text="View"
variant="actionBar">
<data
jcr:primaryType="nt:unstructured"
href.uritemplate.abs="\{+item}.html?wcmmode=disabled"/>
</view>


That's it. The new option 'View' will be shown in the site consoles action toolbar when one or many pages are selected.


View button is added in site console

Enable the View button from the package
You can install the below package to enable/add the view option in site console in Author mode.
https://github.com/arunpatidar02/demo/blob/master/view-as-published-2.zip


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.