2

I have been struggling to find a correct way to implement css and js for my template file, which lies in M2's backend. I put a file named default_head_blocks.xml to implement fullCalendar's css:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <css src="css/fullcalendar.css" />
        <css src="css/fullcalendar.print.css" media="print" />
    </head>
</page>

I don't really know if this is okay or not. Also, requirejs file mapping is quite tricky, at least for me, to implement. The offical devdocs on this is not very helpful. Is there a way to do these with least pain possible?

1 Answer 1

1

You need edit your layout to:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
  <head>
    <css src="Namespace_YourModule::css/fullcalendar.css" />
    <css src="Namespace_YourModule::css/fullcalendar.print.css" media="print" />
  </head>
</page>

This location of .css file: Namespace/YourModule/view/adminhtml/web/css/fullcalendar.css

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.