Virtual Components in AEM 6.4 | Community
Skip to main content
tkaik
March 8, 2019

Virtual Components in AEM 6.4

  • March 8, 2019
  • 1 reply
  • 2880 views

Hello, I would like to use Virtual Components feature to provide different versions of the same component (i.e. same resource type) in the Component Browser. I've found some information about this feature on few AEM documentation pages:

- https://helpx.adobe.com/experience-manager/6-4/sites/developing/using/custom-nodetypes.html#Core  

- https://helpx.adobe.com/experience-manager/6-4/sites/developing/using/components-basics.html

I have created following structure:

{

   "jcr:primaryType":"cq:Component",

   "jcr:title":"My Component",

   "componentGroup":"SomeGroup",

   "cq:design_dialog": { ... }

   },

   "cq:editConfig":{ ... },

   "cq:dialog":{ ... },

   "virtual":{

      "jcr:primaryType":"nt:unstructured",

      "myVirtual1":{

         "jcr:primaryType":"cq:VirtualComponent",

         "jcr:title":"My Virtual 1",

         "componentGroup":"MyGroup",

         "cq:design_dialog":{ ... },

         "cq:editConfig":{ ... }

      },

      "myVirtual2":{

         "jcr:primaryType":"cq:VirtualComponent",

         "jcr:title":"My Virtual 2",

         "componentGroup":"MyGroup",

         "cq:design_dialog":{ ... },

         "cq:editConfig":{ ... }

      }

   }

}

This works very well - after adding component group "MyGroup" to the Allowed Components of Layout Container (in the Policy configuration on Editable Template) I can see each virtual component listed separately in the Components Browser.

I would also like to configure AEM Styles for those components through their design in the policy configuration (I’ve created “cq:design_dialog” definition for the main cq:Component and also for my cq:VirtualComponent’s).

However, after adding my Virtual Components as the “Allowed components” in the Layout Container policy configuration, I am not able to see them displayed as the “pills” on the Layout Container - only regular “cq:Component”s are displayed there:

I know that if I directly add the “parent” component (“My Component”) to the list of “Allowed Components”, then I will be able to see it as the “pill” and configure the Styles (in policy config) for this component, and the styles will be shared by all virtual versions of that component. However I don’t want the “parent” component (“My Component”) to be available to authors in the Component Browser on the pages using that template - I only want the virtual components to be available there. Is there any way to achieve this or the behaviour which I’ve described is expected?

In general, do you know any recommendations on how the virtual components should be used and why they don’t have the same support as regular components (e.g. seperate design dialog/policy config)?

Thank you

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

smacdonald2008
Level 10
March 8, 2019

I have not seen too many articles or discussions about using this property to create a component. Even with the use of Core Components - I am not seeing this property used.

Also - in docs - it says its use is associated with only a foundation component - /libs/foundation/...

smacdonald2008
Level 10
March 8, 2019

Having said that - I will also check with the AEM team about this type of component and its use in TOuch UI.

smacdonald2008
Level 10
March 8, 2019

Heard back - "

I have not seen topics around virtual components in editable templates.n

Virtual Components feature to provide different versions of the same component

Core component implements different versions v1, v2 using slign resource merger. Following COre Components represent best practice.

"