Reg: Component Context getcssclassname | Community
Skip to main content
Shashi_Mulugu
Community Advisor
Community Advisor
April 5, 2021
Solved

Reg: Component Context getcssclassname

  • April 5, 2021
  • 3 replies
  • 1942 views

Hello @daniel_gordon ,

 

I just read your reply on https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/don-t-understand-cssclassnames-in-aem-core-wcm-components-2-0-0/qaq-p/270537 question on what is the use of getcssclassname but i have requirement where i only need Styles added via Style System nothing else..like page component or content component names. Is there any way?

 

@joerghoh @kaushalmall 

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

Hi,

you can use API to access the style system

https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/reference-materials/javadoc/com/day/cq/wcm/commons/policy/ContentPolicyStyle.html

 

but the https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/reference-materials/javadoc/com/day/cq/wcm/api/components/IncludeOptions.html#getCssClassNames() will return the classes which is either included by default or using cq:htmlTag

cq:htmlTag node : This node can be added under a component and can have the following properties:

  • cq:tagName {String} : This can be used to specify a custom HTML tag to be used for wrapping the components instead of the default DIV element.
  • class {String} : This can be used to specify css class names to be added to the wrapper.

3 replies

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
April 6, 2021

Hi,

you can use API to access the style system

https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/reference-materials/javadoc/com/day/cq/wcm/commons/policy/ContentPolicyStyle.html

 

but the https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/reference-materials/javadoc/com/day/cq/wcm/api/components/IncludeOptions.html#getCssClassNames() will return the classes which is either included by default or using cq:htmlTag

cq:htmlTag node : This node can be added under a component and can have the following properties:

  • cq:tagName {String} : This can be used to specify a custom HTML tag to be used for wrapping the components instead of the default DIV element.
  • class {String} : This can be used to specify css class names to be added to the wrapper.
Arun Patidar
Shashi_Mulugu
Community Advisor
Community Advisor
April 6, 2021
@arunpatidar Thank you for the reply. Yes I saw the api but unable to find any reference implementation on how exactly we can invoke the API within component context or from sling model and get styles attached a component or a page.. also for the getcssclassname() if you have seen the link i have quoted, Daniels was saying it will even fetch styles attached via style system as well. so got curious to know from other side.
Pawan-Gupta
Level 8
April 6, 2021

also, just to add an idea and not doing framework layer customization(if it is not need global level for many instances)

 

why not to use componentContext or includoption to disable the tag (div/span etc...) decoration only in publish/disabled mode and read the styles using contentpolicystyle and generate desired div/span container with style class (only in publish/disable mode) inside component only (as top container).

 

other way around to look at it.

 

thanks!!

Shashi_Mulugu
Community Advisor
Community Advisor
April 7, 2021

Correct answer in comments