Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Custom CSS - Editable Templates

Avatar

Level 2

Hi All,

 

I have created an editable template in my project. If i open the template structure there is no such css file is loading. And in our project all the components css will be merged in a single file which we will be placed in etc/designs/clientlibs/projectname/sample.css.

 

I want this sample.css file to be loaded when i hit the template structure so that the structure looks good.

 

Is it possible to call the existing css. If yes, can you please help me with the steps.

 

Thanks in advance.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @sai_santhosht50,

 

Go to  Tools -> Templates; Select your required template --> Click on edit --> Go to page policy --> Properties --> Clientlibs, add your client library category so that you can see the css/js loading.

 

KiranVedantam1992_0-1612793770874.png

 

Hope this helps.

 

Thanks,

Kiran Vedantam.

View solution in original post

8 Replies

Avatar

Correct answer by
Community Advisor

Hi @sai_santhosht50,

 

Go to  Tools -> Templates; Select your required template --> Click on edit --> Go to page policy --> Properties --> Clientlibs, add your client library category so that you can see the css/js loading.

 

KiranVedantam1992_0-1612793770874.png

 

Hope this helps.

 

Thanks,

Kiran Vedantam.

Hi @Kiran_Vedantam, Thanks for your reply. For my custom client libs i could see there are 2 properties called dependencies & categories , i have tries both of these in page policy bit css/js didnt loaded in template structure.
Can you please confirm me if we add it at policy level , will it loads at template structure level or will it loads in the pages created with this template.

Avatar

Community Advisor
Hi, you need to add the category in the field mentioned above. The client-libs will be available in the template level with this action, which in turn will make the css and js available for the components authored

Avatar

Community Advisor

@sai_santhosht50,

You will need to make sure that your client library is properly created. Can you find the client library from here? http://localhost:4502/libs/granite/ui/content/dumplibs.html

Once when your client library with the category exists, you can insert the client category in the editable template's page policy page. 

As an example, I have included 2 valid client libraries of: cq.handlebars && cq.jquery (http://localhost:4502/editor.html/conf/we-retail/settings/wcm/templates/content-page/structure.html)

BrianKasingli_1-1612821676595.png

Results in the page source, I can see client libraries loading as expected. The CSS files will be loaded in the <head> while the JS files will be loaded before the closing of the </body>
view-source:http://localhost:4502/conf/we-retail/settings/wcm/templates/content-page/structure.html?wcmmode=disabled

BrianKasingli_2-1612821751559.png

 

 

 

 

 

 

Avatar

Level 2
HI @briyanKasingli - I can find my client libs here -> http://localhost:4502/libs/granite/ui/content/dumplibs.html , and as you said i have written the category at page policy of template strucutre. After that when i load the template strucutre i dont see my css is loading in the template. Can you let me know if we can do it in an another way.

Avatar

Community Advisor
Might be a permission problem, do you have allowProxy = true enabled? Can you share with my the path client libs of your CSS? example /etc.clientlibs/my-site/clientlibs/base.css

Avatar

Community Advisor

Hi @sai_santhosht50,

Clientlibs included at Page policy level is included in /apps/core/wcm/components/page/v2/page/head.html. So cross check if your editable template's page component(as mentioned via sling:resourceType in say, /conf/we-retail/settings/wcm/templates/content-page/structure/jcr:content) is inheriting from core page component.

If it is and still not coming, try the below

  • Include the clientlib in customheaderlibs.html that is overwritten in your page component. 
  • Or try using direct link tag with path to your CSS file (as a last option just to narrow down the issue)

No clue still, share the details of how your page component(using which editable template would have been created) is designed.