Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Applying CSS/Clientlib to content in editor

SiriusRex
Level 2
Level 2

TL;DR - I'm trying to apply a clientlib to the page content in editor.html without it being included in the published content.

 

AEM has a clientlib for FontAwesome here: /etc/clientlibs/acs-commons/vendor/fontawesome/css/font-awesome.css.

This is included in editor.html, but because the content of the page is actually in an iframe, the font-awesome styles don't apply to any of the components. I'm trying to figure out how I can either 1) use the existing CSS call to apply to the contents in the iframe or 2) find a way to include the font awesome CSS in the page content just in the authoring mode and not have it get included when the page gets published. It's a long complicated story, but our content is being placed inside a wrapper that already calls font awesome (but this wrapper isn't in AEM). I could just include it into the page template, but then we would have two calls loading the CSS (in the header, and in the page content).

 

Looking for any suggestions of how I might make this work. Thanks.

1 Accepted Solution
Nupur_Jain
Correct answer by
Community Advisor
Community Advisor

Hi @SiriusRex 

 

The clinetlib of the css file is "acs-commons.fontawesome". You can check first if the wcmmode is edit and then include the cientlib in your site header like this:

 

 

<sly data-sly-test="${wcmmode.edit} "data-sly-use.clientLib="/libs/granite/sightly/templates/clientlib.html"
     data-sly-call="${clientlib.css @ categories='acs-commons.fontawesome'}"/>

 

 

Since the page in editor.html loads in iframe, you will have to include this statement in site header html.

 

Hope it helps!

Thanks

Nupur

View solution in original post

0 Replies
Nirmal_Jose
Community Advisor
Community Advisor

use the category cq.authoring.editor on the clientlibs you want to load only on editor mode. 

Adobe loads all authoring component clientlibs using this category. Reference at [1]

 

[1] - /libs/cq/gui/components/authoring/searchfield/clientlibs/searchfield

Nupur_Jain
Correct answer by
Community Advisor
Community Advisor

Hi @SiriusRex 

 

The clinetlib of the css file is "acs-commons.fontawesome". You can check first if the wcmmode is edit and then include the cientlib in your site header like this:

 

 

<sly data-sly-test="${wcmmode.edit} "data-sly-use.clientLib="/libs/granite/sightly/templates/clientlib.html"
     data-sly-call="${clientlib.css @ categories='acs-commons.fontawesome'}"/>

 

 

Since the page in editor.html loads in iframe, you will have to include this statement in site header html.

 

Hope it helps!

Thanks

Nupur

View solution in original post

SiriusRex
Level 2
Level 2

Hello again, @Nupur_Jain, thanks for your original reply. It helped me greatly. Now, however, I've run into a new situation: I want to be able to have the clientlib available in AEM's "View as Published" mode, which appends "wcmmode=disabled" to the end of the authoring URL. I thought I could test for "wcmmode.disabled = 'true'" but it turns out that when you publish the page, the value for wcmmode.disabled is also true, and so the clientlib is getting included and published along with the page. Any ideas how to distinguish between the authoring "view as published" and the actual live environment?