Determine whether running instance is author or publish

Issue

In your code, you want to find out if the instance running your code is an author instance or a publish instance.

Solution

You can use the following code in your components and templates to find out if the running instance is an author or a publish.

DeliveryHttpServletRequest cqRequest = (DeliveryHttpServletRequest) request;

// flag to indicate whether instance is Author or Publish boolean isAuthor = !cqRequest.getCmsService().getDisplayControlSet(cqRequest).equals(DisplayControlSet.SHOW);

// flag to indicate whether instance is in preview/show mode boolean isShowMode = (cqRequest.getCmsService().getDisplayControlSet(cqRequest).equals(DisplayControlSet.SHOWMODE) || "ShowMode".equals(cqRequest.getParameter("Show")) );

 Adobe

Get help faster and easier

New user?

Adobe MAX 2024

Adobe MAX
The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX

The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX 2024

Adobe MAX
The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX

The Creativity Conference

Oct 14–16 Miami Beach and online