Magento2: How to add different custom css file on specific CMS pages












4















I tried so may things but unable to add the CSS & JS files for each Static CMS pages.
I know if CSS can be added in cms_page_view.xml but this will reflect in all pages.



is there anyway to add different CSS files for different static pages.










share|improve this question





























    4















    I tried so may things but unable to add the CSS & JS files for each Static CMS pages.
    I know if CSS can be added in cms_page_view.xml but this will reflect in all pages.



    is there anyway to add different CSS files for different static pages.










    share|improve this question



























      4












      4








      4


      1






      I tried so may things but unable to add the CSS & JS files for each Static CMS pages.
      I know if CSS can be added in cms_page_view.xml but this will reflect in all pages.



      is there anyway to add different CSS files for different static pages.










      share|improve this question
















      I tried so may things but unable to add the CSS & JS files for each Static CMS pages.
      I know if CSS can be added in cms_page_view.xml but this will reflect in all pages.



      is there anyway to add different CSS files for different static pages.







      magento2 magento-2.1 magento-2.0.2 cms-pages






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 20 '16 at 14:41









      Klettseb

      3,05031751




      3,05031751










      asked Jul 20 '16 at 14:34









      Mohammad MujassamMohammad Mujassam

      1,1471227




      1,1471227






















          4 Answers
          4






          active

          oldest

          votes


















          5














          You can add Layout Update XML update



          GOTO ADMIN -> Content -> Pages -> Edit page -> Design -> Layout Update XML


          With the content :



          <head>
          <css src="Namespace_YourModule::css/styles.css"/>
          </head>


          Then there is a bug in Magento 2, you need to override the default Magento 2 vendor/magento/framework/View/Layout/etc/page_layout.xsd validation file.



          A workaround, not a clean solution, but waiting Magento 2 to allow override xsd files



          app/code/Vendor/Module/etc/di.xml



          <preference for="MagentoFrameworkViewModelLayoutUpdateValidator" type="VendorModuleModelLayoutUpdateValidator" />


          app/code/Vendor/Module/etc/page_layout.xsd



          <?xml version="1.0" encoding="UTF-8"?>
          <!--
          /**
          * Copyright © 2013-2017 Magento, Inc. All rights reserved.
          * See COPYING.txt for license details.
          */
          -->
          <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
          <xs:include schemaLocation="urn:magento:framework:View/Layout/etc/elements.xsd"/>
          <xs:include schemaLocation="urn:magento:framework:View/Layout/etc/head.xsd"/>
          <xs:include schemaLocation="urn:magento:framework:View/Layout/etc/body.xsd"/>

          <xs:complexType name="pageLayoutType">
          <xs:sequence minOccurs="0" maxOccurs="unbounded">
          <xs:element ref="referenceContainer" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element ref="container" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element ref="update" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element ref="move" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element name="head" type="headType" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element name="body" type="bodyType" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
          </xs:complexType>

          <xs:element name="layout" type="pageLayoutType">
          <xs:unique name="containerKey">
          <xs:selector xpath=".//container"/>
          <xs:field xpath="@name"/>
          </xs:unique>
          </xs:element>
          </xs:schema>


          app/code/Vendor/Module/Model/Layout/Update/Validator.php



          <?php
          namespace HublotSetupModelLayoutUpdate;

          use MagentoFrameworkConfigDomUrnResolver;

          class Validator extends MagentoFrameworkViewModelLayoutUpdateValidator
          {
          const LAYOUT_SCHEMA_PAGE_HANDLE = 'page_layout';

          const LAYOUT_SCHEMA_MERGED = 'layout_merged';

          /**
          * @param MagentoFrameworkConfigDomFactory $domConfigFactory
          * @param MagentoFrameworkConfigDomUrnResolver $urnResolver
          */
          public function __construct(
          MagentoFrameworkConfigDomFactory $domConfigFactory,
          UrnResolver $urnResolver
          ) {
          $this->_domConfigFactory = $domConfigFactory;
          $this->_initMessageTemplates();
          $this->_xsdSchemas = [
          self::LAYOUT_SCHEMA_PAGE_HANDLE => $urnResolver->getRealPath(
          'urn:hublot:module:Hublot_Setup:etc/page_layout.xsd'
          ),
          self::LAYOUT_SCHEMA_MERGED => $urnResolver->getRealPath(
          'urn:magento:framework:View/Layout/etc/layout_merged.xsd'
          ),
          ];
          }
          }





          share|improve this answer
























          • For reference to see when this is eventually fixed, this is the Magento bug in question: github.com/magento/magento2/issues/4454

            – Scott Buchanan
            Oct 5 '17 at 14:26











          • It is indeed a bug I have same issue 2.2.2 there is the fix :github.com/magento/magento2/commit/…

            – Juliano Vargas
            Apr 30 '18 at 10:39





















          0














          You can add custom css like below:
          make an entry in layout file



           <page>   
          <head>
          <css src="css/ie-9.css" ie_condition="IE 9" />
          <css src="Magento_Catalog::css/custom.css" />
          <css src="Custom_SampleModule::css/custom.css"/>
          </head>
          </page>





          share|improve this answer































            0














            I found that Franck Garnier's does not quite work on 2.1.16.



            I had to change the last file, Validator.php, a bit to get it to work as follows.



            namespace VendorCmsLayoutFixModelLayoutUpdate;

            use MagentoFrameworkAppObjectManager;
            use MagentoFrameworkConfigDomUrnResolver;
            use MagentoFrameworkConfigDomFactory;
            use MagentoFrameworkConfigValidationStateInterface;

            class Validator extends MagentoFrameworkViewModelLayoutUpdateValidator
            {
            const LAYOUT_SCHEMA_PAGE_HANDLE = 'page_layout';

            const LAYOUT_SCHEMA_MERGED = 'layout_merged';

            private $validationState;

            public function __construct(
            DomFactory $domConfigFactory,
            UrnResolver $urnResolver,
            ValidationStateInterface $validationState = null
            ) {
            parent::__construct($domConfigFactory, $urnResolver);
            $this->_xsdSchemas = [
            self::LAYOUT_SCHEMA_PAGE_HANDLE => $urnResolver->getRealPath(
            'urn:vendor:module:Vendor_CmsLayoutFix:etc/page_layout.xsd'
            ),
            self::LAYOUT_SCHEMA_MERGED => $urnResolver->getRealPath(
            'urn:magento:framework:View/Layout/etc/layout_merged.xsd'
            ),
            ];
            }
            }


            WHERE:



            vendor = Vendor



            module = CmsLayoutFix






            share|improve this answer








            New contributor




            Jason is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.




























              -1














              In magento all CMS pages have an option of Layout Update XML update .Just Call your Custom code there also add CSS or JS .



              Admin CMS Pages



              GOTO ADMIN -> Content -> Pages -> Edit page -> Design -> Layout Update XML


              add below call



              <head>
              <css src="Namespace_YourModule::css/styles.css"/>
              </head>





              share|improve this answer
























              • this works in page layout configuration not in Layout Update XML , hope you checked...

                – Mohammad Mujassam
                Jul 21 '16 at 4:44











              • It is working fine I have tested this code . just remove "Namespace_YourModule::" and set in to "Layout Update XML" and refresh you Cache so you can show in that page only.

                – Hitesh Vaghasiya
                Jul 21 '16 at 18:59






              • 1





                Please correct the XML data and try again. Element 'head': This element is not expected. Expected is one of ( referenceContainer, container, update, move ). Line: 1 this we will get if we put anything else apart from above four Element. I am using magento 2.0.7

                – Mohammad Mujassam
                Jul 22 '16 at 4:40








              • 1





                Yeah, this worked for me. Just remember to flush the cache after you change the layout for the cms page to pickup the change.

                – Dallas Clarke
                Dec 13 '17 at 3:23











              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "479"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f126646%2fmagento2-how-to-add-different-custom-css-file-on-specific-cms-pages%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              4 Answers
              4






              active

              oldest

              votes








              4 Answers
              4






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              5














              You can add Layout Update XML update



              GOTO ADMIN -> Content -> Pages -> Edit page -> Design -> Layout Update XML


              With the content :



              <head>
              <css src="Namespace_YourModule::css/styles.css"/>
              </head>


              Then there is a bug in Magento 2, you need to override the default Magento 2 vendor/magento/framework/View/Layout/etc/page_layout.xsd validation file.



              A workaround, not a clean solution, but waiting Magento 2 to allow override xsd files



              app/code/Vendor/Module/etc/di.xml



              <preference for="MagentoFrameworkViewModelLayoutUpdateValidator" type="VendorModuleModelLayoutUpdateValidator" />


              app/code/Vendor/Module/etc/page_layout.xsd



              <?xml version="1.0" encoding="UTF-8"?>
              <!--
              /**
              * Copyright © 2013-2017 Magento, Inc. All rights reserved.
              * See COPYING.txt for license details.
              */
              -->
              <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
              <xs:include schemaLocation="urn:magento:framework:View/Layout/etc/elements.xsd"/>
              <xs:include schemaLocation="urn:magento:framework:View/Layout/etc/head.xsd"/>
              <xs:include schemaLocation="urn:magento:framework:View/Layout/etc/body.xsd"/>

              <xs:complexType name="pageLayoutType">
              <xs:sequence minOccurs="0" maxOccurs="unbounded">
              <xs:element ref="referenceContainer" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element ref="container" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element ref="update" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element ref="move" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element name="head" type="headType" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element name="body" type="bodyType" minOccurs="0" maxOccurs="unbounded"/>
              </xs:sequence>
              </xs:complexType>

              <xs:element name="layout" type="pageLayoutType">
              <xs:unique name="containerKey">
              <xs:selector xpath=".//container"/>
              <xs:field xpath="@name"/>
              </xs:unique>
              </xs:element>
              </xs:schema>


              app/code/Vendor/Module/Model/Layout/Update/Validator.php



              <?php
              namespace HublotSetupModelLayoutUpdate;

              use MagentoFrameworkConfigDomUrnResolver;

              class Validator extends MagentoFrameworkViewModelLayoutUpdateValidator
              {
              const LAYOUT_SCHEMA_PAGE_HANDLE = 'page_layout';

              const LAYOUT_SCHEMA_MERGED = 'layout_merged';

              /**
              * @param MagentoFrameworkConfigDomFactory $domConfigFactory
              * @param MagentoFrameworkConfigDomUrnResolver $urnResolver
              */
              public function __construct(
              MagentoFrameworkConfigDomFactory $domConfigFactory,
              UrnResolver $urnResolver
              ) {
              $this->_domConfigFactory = $domConfigFactory;
              $this->_initMessageTemplates();
              $this->_xsdSchemas = [
              self::LAYOUT_SCHEMA_PAGE_HANDLE => $urnResolver->getRealPath(
              'urn:hublot:module:Hublot_Setup:etc/page_layout.xsd'
              ),
              self::LAYOUT_SCHEMA_MERGED => $urnResolver->getRealPath(
              'urn:magento:framework:View/Layout/etc/layout_merged.xsd'
              ),
              ];
              }
              }





              share|improve this answer
























              • For reference to see when this is eventually fixed, this is the Magento bug in question: github.com/magento/magento2/issues/4454

                – Scott Buchanan
                Oct 5 '17 at 14:26











              • It is indeed a bug I have same issue 2.2.2 there is the fix :github.com/magento/magento2/commit/…

                – Juliano Vargas
                Apr 30 '18 at 10:39


















              5














              You can add Layout Update XML update



              GOTO ADMIN -> Content -> Pages -> Edit page -> Design -> Layout Update XML


              With the content :



              <head>
              <css src="Namespace_YourModule::css/styles.css"/>
              </head>


              Then there is a bug in Magento 2, you need to override the default Magento 2 vendor/magento/framework/View/Layout/etc/page_layout.xsd validation file.



              A workaround, not a clean solution, but waiting Magento 2 to allow override xsd files



              app/code/Vendor/Module/etc/di.xml



              <preference for="MagentoFrameworkViewModelLayoutUpdateValidator" type="VendorModuleModelLayoutUpdateValidator" />


              app/code/Vendor/Module/etc/page_layout.xsd



              <?xml version="1.0" encoding="UTF-8"?>
              <!--
              /**
              * Copyright © 2013-2017 Magento, Inc. All rights reserved.
              * See COPYING.txt for license details.
              */
              -->
              <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
              <xs:include schemaLocation="urn:magento:framework:View/Layout/etc/elements.xsd"/>
              <xs:include schemaLocation="urn:magento:framework:View/Layout/etc/head.xsd"/>
              <xs:include schemaLocation="urn:magento:framework:View/Layout/etc/body.xsd"/>

              <xs:complexType name="pageLayoutType">
              <xs:sequence minOccurs="0" maxOccurs="unbounded">
              <xs:element ref="referenceContainer" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element ref="container" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element ref="update" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element ref="move" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element name="head" type="headType" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element name="body" type="bodyType" minOccurs="0" maxOccurs="unbounded"/>
              </xs:sequence>
              </xs:complexType>

              <xs:element name="layout" type="pageLayoutType">
              <xs:unique name="containerKey">
              <xs:selector xpath=".//container"/>
              <xs:field xpath="@name"/>
              </xs:unique>
              </xs:element>
              </xs:schema>


              app/code/Vendor/Module/Model/Layout/Update/Validator.php



              <?php
              namespace HublotSetupModelLayoutUpdate;

              use MagentoFrameworkConfigDomUrnResolver;

              class Validator extends MagentoFrameworkViewModelLayoutUpdateValidator
              {
              const LAYOUT_SCHEMA_PAGE_HANDLE = 'page_layout';

              const LAYOUT_SCHEMA_MERGED = 'layout_merged';

              /**
              * @param MagentoFrameworkConfigDomFactory $domConfigFactory
              * @param MagentoFrameworkConfigDomUrnResolver $urnResolver
              */
              public function __construct(
              MagentoFrameworkConfigDomFactory $domConfigFactory,
              UrnResolver $urnResolver
              ) {
              $this->_domConfigFactory = $domConfigFactory;
              $this->_initMessageTemplates();
              $this->_xsdSchemas = [
              self::LAYOUT_SCHEMA_PAGE_HANDLE => $urnResolver->getRealPath(
              'urn:hublot:module:Hublot_Setup:etc/page_layout.xsd'
              ),
              self::LAYOUT_SCHEMA_MERGED => $urnResolver->getRealPath(
              'urn:magento:framework:View/Layout/etc/layout_merged.xsd'
              ),
              ];
              }
              }





              share|improve this answer
























              • For reference to see when this is eventually fixed, this is the Magento bug in question: github.com/magento/magento2/issues/4454

                – Scott Buchanan
                Oct 5 '17 at 14:26











              • It is indeed a bug I have same issue 2.2.2 there is the fix :github.com/magento/magento2/commit/…

                – Juliano Vargas
                Apr 30 '18 at 10:39
















              5












              5








              5







              You can add Layout Update XML update



              GOTO ADMIN -> Content -> Pages -> Edit page -> Design -> Layout Update XML


              With the content :



              <head>
              <css src="Namespace_YourModule::css/styles.css"/>
              </head>


              Then there is a bug in Magento 2, you need to override the default Magento 2 vendor/magento/framework/View/Layout/etc/page_layout.xsd validation file.



              A workaround, not a clean solution, but waiting Magento 2 to allow override xsd files



              app/code/Vendor/Module/etc/di.xml



              <preference for="MagentoFrameworkViewModelLayoutUpdateValidator" type="VendorModuleModelLayoutUpdateValidator" />


              app/code/Vendor/Module/etc/page_layout.xsd



              <?xml version="1.0" encoding="UTF-8"?>
              <!--
              /**
              * Copyright © 2013-2017 Magento, Inc. All rights reserved.
              * See COPYING.txt for license details.
              */
              -->
              <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
              <xs:include schemaLocation="urn:magento:framework:View/Layout/etc/elements.xsd"/>
              <xs:include schemaLocation="urn:magento:framework:View/Layout/etc/head.xsd"/>
              <xs:include schemaLocation="urn:magento:framework:View/Layout/etc/body.xsd"/>

              <xs:complexType name="pageLayoutType">
              <xs:sequence minOccurs="0" maxOccurs="unbounded">
              <xs:element ref="referenceContainer" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element ref="container" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element ref="update" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element ref="move" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element name="head" type="headType" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element name="body" type="bodyType" minOccurs="0" maxOccurs="unbounded"/>
              </xs:sequence>
              </xs:complexType>

              <xs:element name="layout" type="pageLayoutType">
              <xs:unique name="containerKey">
              <xs:selector xpath=".//container"/>
              <xs:field xpath="@name"/>
              </xs:unique>
              </xs:element>
              </xs:schema>


              app/code/Vendor/Module/Model/Layout/Update/Validator.php



              <?php
              namespace HublotSetupModelLayoutUpdate;

              use MagentoFrameworkConfigDomUrnResolver;

              class Validator extends MagentoFrameworkViewModelLayoutUpdateValidator
              {
              const LAYOUT_SCHEMA_PAGE_HANDLE = 'page_layout';

              const LAYOUT_SCHEMA_MERGED = 'layout_merged';

              /**
              * @param MagentoFrameworkConfigDomFactory $domConfigFactory
              * @param MagentoFrameworkConfigDomUrnResolver $urnResolver
              */
              public function __construct(
              MagentoFrameworkConfigDomFactory $domConfigFactory,
              UrnResolver $urnResolver
              ) {
              $this->_domConfigFactory = $domConfigFactory;
              $this->_initMessageTemplates();
              $this->_xsdSchemas = [
              self::LAYOUT_SCHEMA_PAGE_HANDLE => $urnResolver->getRealPath(
              'urn:hublot:module:Hublot_Setup:etc/page_layout.xsd'
              ),
              self::LAYOUT_SCHEMA_MERGED => $urnResolver->getRealPath(
              'urn:magento:framework:View/Layout/etc/layout_merged.xsd'
              ),
              ];
              }
              }





              share|improve this answer













              You can add Layout Update XML update



              GOTO ADMIN -> Content -> Pages -> Edit page -> Design -> Layout Update XML


              With the content :



              <head>
              <css src="Namespace_YourModule::css/styles.css"/>
              </head>


              Then there is a bug in Magento 2, you need to override the default Magento 2 vendor/magento/framework/View/Layout/etc/page_layout.xsd validation file.



              A workaround, not a clean solution, but waiting Magento 2 to allow override xsd files



              app/code/Vendor/Module/etc/di.xml



              <preference for="MagentoFrameworkViewModelLayoutUpdateValidator" type="VendorModuleModelLayoutUpdateValidator" />


              app/code/Vendor/Module/etc/page_layout.xsd



              <?xml version="1.0" encoding="UTF-8"?>
              <!--
              /**
              * Copyright © 2013-2017 Magento, Inc. All rights reserved.
              * See COPYING.txt for license details.
              */
              -->
              <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
              <xs:include schemaLocation="urn:magento:framework:View/Layout/etc/elements.xsd"/>
              <xs:include schemaLocation="urn:magento:framework:View/Layout/etc/head.xsd"/>
              <xs:include schemaLocation="urn:magento:framework:View/Layout/etc/body.xsd"/>

              <xs:complexType name="pageLayoutType">
              <xs:sequence minOccurs="0" maxOccurs="unbounded">
              <xs:element ref="referenceContainer" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element ref="container" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element ref="update" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element ref="move" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element name="head" type="headType" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element name="body" type="bodyType" minOccurs="0" maxOccurs="unbounded"/>
              </xs:sequence>
              </xs:complexType>

              <xs:element name="layout" type="pageLayoutType">
              <xs:unique name="containerKey">
              <xs:selector xpath=".//container"/>
              <xs:field xpath="@name"/>
              </xs:unique>
              </xs:element>
              </xs:schema>


              app/code/Vendor/Module/Model/Layout/Update/Validator.php



              <?php
              namespace HublotSetupModelLayoutUpdate;

              use MagentoFrameworkConfigDomUrnResolver;

              class Validator extends MagentoFrameworkViewModelLayoutUpdateValidator
              {
              const LAYOUT_SCHEMA_PAGE_HANDLE = 'page_layout';

              const LAYOUT_SCHEMA_MERGED = 'layout_merged';

              /**
              * @param MagentoFrameworkConfigDomFactory $domConfigFactory
              * @param MagentoFrameworkConfigDomUrnResolver $urnResolver
              */
              public function __construct(
              MagentoFrameworkConfigDomFactory $domConfigFactory,
              UrnResolver $urnResolver
              ) {
              $this->_domConfigFactory = $domConfigFactory;
              $this->_initMessageTemplates();
              $this->_xsdSchemas = [
              self::LAYOUT_SCHEMA_PAGE_HANDLE => $urnResolver->getRealPath(
              'urn:hublot:module:Hublot_Setup:etc/page_layout.xsd'
              ),
              self::LAYOUT_SCHEMA_MERGED => $urnResolver->getRealPath(
              'urn:magento:framework:View/Layout/etc/layout_merged.xsd'
              ),
              ];
              }
              }






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Mar 27 '17 at 10:23









              Franck GarnierFranck Garnier

              2,016826




              2,016826













              • For reference to see when this is eventually fixed, this is the Magento bug in question: github.com/magento/magento2/issues/4454

                – Scott Buchanan
                Oct 5 '17 at 14:26











              • It is indeed a bug I have same issue 2.2.2 there is the fix :github.com/magento/magento2/commit/…

                – Juliano Vargas
                Apr 30 '18 at 10:39





















              • For reference to see when this is eventually fixed, this is the Magento bug in question: github.com/magento/magento2/issues/4454

                – Scott Buchanan
                Oct 5 '17 at 14:26











              • It is indeed a bug I have same issue 2.2.2 there is the fix :github.com/magento/magento2/commit/…

                – Juliano Vargas
                Apr 30 '18 at 10:39



















              For reference to see when this is eventually fixed, this is the Magento bug in question: github.com/magento/magento2/issues/4454

              – Scott Buchanan
              Oct 5 '17 at 14:26





              For reference to see when this is eventually fixed, this is the Magento bug in question: github.com/magento/magento2/issues/4454

              – Scott Buchanan
              Oct 5 '17 at 14:26













              It is indeed a bug I have same issue 2.2.2 there is the fix :github.com/magento/magento2/commit/…

              – Juliano Vargas
              Apr 30 '18 at 10:39







              It is indeed a bug I have same issue 2.2.2 there is the fix :github.com/magento/magento2/commit/…

              – Juliano Vargas
              Apr 30 '18 at 10:39















              0














              You can add custom css like below:
              make an entry in layout file



               <page>   
              <head>
              <css src="css/ie-9.css" ie_condition="IE 9" />
              <css src="Magento_Catalog::css/custom.css" />
              <css src="Custom_SampleModule::css/custom.css"/>
              </head>
              </page>





              share|improve this answer




























                0














                You can add custom css like below:
                make an entry in layout file



                 <page>   
                <head>
                <css src="css/ie-9.css" ie_condition="IE 9" />
                <css src="Magento_Catalog::css/custom.css" />
                <css src="Custom_SampleModule::css/custom.css"/>
                </head>
                </page>





                share|improve this answer


























                  0












                  0








                  0







                  You can add custom css like below:
                  make an entry in layout file



                   <page>   
                  <head>
                  <css src="css/ie-9.css" ie_condition="IE 9" />
                  <css src="Magento_Catalog::css/custom.css" />
                  <css src="Custom_SampleModule::css/custom.css"/>
                  </head>
                  </page>





                  share|improve this answer













                  You can add custom css like below:
                  make an entry in layout file



                   <page>   
                  <head>
                  <css src="css/ie-9.css" ie_condition="IE 9" />
                  <css src="Magento_Catalog::css/custom.css" />
                  <css src="Custom_SampleModule::css/custom.css"/>
                  </head>
                  </page>






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 11 '17 at 16:20









                  Pramod KharadePramod Kharade

                  1,636928




                  1,636928























                      0














                      I found that Franck Garnier's does not quite work on 2.1.16.



                      I had to change the last file, Validator.php, a bit to get it to work as follows.



                      namespace VendorCmsLayoutFixModelLayoutUpdate;

                      use MagentoFrameworkAppObjectManager;
                      use MagentoFrameworkConfigDomUrnResolver;
                      use MagentoFrameworkConfigDomFactory;
                      use MagentoFrameworkConfigValidationStateInterface;

                      class Validator extends MagentoFrameworkViewModelLayoutUpdateValidator
                      {
                      const LAYOUT_SCHEMA_PAGE_HANDLE = 'page_layout';

                      const LAYOUT_SCHEMA_MERGED = 'layout_merged';

                      private $validationState;

                      public function __construct(
                      DomFactory $domConfigFactory,
                      UrnResolver $urnResolver,
                      ValidationStateInterface $validationState = null
                      ) {
                      parent::__construct($domConfigFactory, $urnResolver);
                      $this->_xsdSchemas = [
                      self::LAYOUT_SCHEMA_PAGE_HANDLE => $urnResolver->getRealPath(
                      'urn:vendor:module:Vendor_CmsLayoutFix:etc/page_layout.xsd'
                      ),
                      self::LAYOUT_SCHEMA_MERGED => $urnResolver->getRealPath(
                      'urn:magento:framework:View/Layout/etc/layout_merged.xsd'
                      ),
                      ];
                      }
                      }


                      WHERE:



                      vendor = Vendor



                      module = CmsLayoutFix






                      share|improve this answer








                      New contributor




                      Jason is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.

























                        0














                        I found that Franck Garnier's does not quite work on 2.1.16.



                        I had to change the last file, Validator.php, a bit to get it to work as follows.



                        namespace VendorCmsLayoutFixModelLayoutUpdate;

                        use MagentoFrameworkAppObjectManager;
                        use MagentoFrameworkConfigDomUrnResolver;
                        use MagentoFrameworkConfigDomFactory;
                        use MagentoFrameworkConfigValidationStateInterface;

                        class Validator extends MagentoFrameworkViewModelLayoutUpdateValidator
                        {
                        const LAYOUT_SCHEMA_PAGE_HANDLE = 'page_layout';

                        const LAYOUT_SCHEMA_MERGED = 'layout_merged';

                        private $validationState;

                        public function __construct(
                        DomFactory $domConfigFactory,
                        UrnResolver $urnResolver,
                        ValidationStateInterface $validationState = null
                        ) {
                        parent::__construct($domConfigFactory, $urnResolver);
                        $this->_xsdSchemas = [
                        self::LAYOUT_SCHEMA_PAGE_HANDLE => $urnResolver->getRealPath(
                        'urn:vendor:module:Vendor_CmsLayoutFix:etc/page_layout.xsd'
                        ),
                        self::LAYOUT_SCHEMA_MERGED => $urnResolver->getRealPath(
                        'urn:magento:framework:View/Layout/etc/layout_merged.xsd'
                        ),
                        ];
                        }
                        }


                        WHERE:



                        vendor = Vendor



                        module = CmsLayoutFix






                        share|improve this answer








                        New contributor




                        Jason is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.























                          0












                          0








                          0







                          I found that Franck Garnier's does not quite work on 2.1.16.



                          I had to change the last file, Validator.php, a bit to get it to work as follows.



                          namespace VendorCmsLayoutFixModelLayoutUpdate;

                          use MagentoFrameworkAppObjectManager;
                          use MagentoFrameworkConfigDomUrnResolver;
                          use MagentoFrameworkConfigDomFactory;
                          use MagentoFrameworkConfigValidationStateInterface;

                          class Validator extends MagentoFrameworkViewModelLayoutUpdateValidator
                          {
                          const LAYOUT_SCHEMA_PAGE_HANDLE = 'page_layout';

                          const LAYOUT_SCHEMA_MERGED = 'layout_merged';

                          private $validationState;

                          public function __construct(
                          DomFactory $domConfigFactory,
                          UrnResolver $urnResolver,
                          ValidationStateInterface $validationState = null
                          ) {
                          parent::__construct($domConfigFactory, $urnResolver);
                          $this->_xsdSchemas = [
                          self::LAYOUT_SCHEMA_PAGE_HANDLE => $urnResolver->getRealPath(
                          'urn:vendor:module:Vendor_CmsLayoutFix:etc/page_layout.xsd'
                          ),
                          self::LAYOUT_SCHEMA_MERGED => $urnResolver->getRealPath(
                          'urn:magento:framework:View/Layout/etc/layout_merged.xsd'
                          ),
                          ];
                          }
                          }


                          WHERE:



                          vendor = Vendor



                          module = CmsLayoutFix






                          share|improve this answer








                          New contributor




                          Jason is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.










                          I found that Franck Garnier's does not quite work on 2.1.16.



                          I had to change the last file, Validator.php, a bit to get it to work as follows.



                          namespace VendorCmsLayoutFixModelLayoutUpdate;

                          use MagentoFrameworkAppObjectManager;
                          use MagentoFrameworkConfigDomUrnResolver;
                          use MagentoFrameworkConfigDomFactory;
                          use MagentoFrameworkConfigValidationStateInterface;

                          class Validator extends MagentoFrameworkViewModelLayoutUpdateValidator
                          {
                          const LAYOUT_SCHEMA_PAGE_HANDLE = 'page_layout';

                          const LAYOUT_SCHEMA_MERGED = 'layout_merged';

                          private $validationState;

                          public function __construct(
                          DomFactory $domConfigFactory,
                          UrnResolver $urnResolver,
                          ValidationStateInterface $validationState = null
                          ) {
                          parent::__construct($domConfigFactory, $urnResolver);
                          $this->_xsdSchemas = [
                          self::LAYOUT_SCHEMA_PAGE_HANDLE => $urnResolver->getRealPath(
                          'urn:vendor:module:Vendor_CmsLayoutFix:etc/page_layout.xsd'
                          ),
                          self::LAYOUT_SCHEMA_MERGED => $urnResolver->getRealPath(
                          'urn:magento:framework:View/Layout/etc/layout_merged.xsd'
                          ),
                          ];
                          }
                          }


                          WHERE:



                          vendor = Vendor



                          module = CmsLayoutFix







                          share|improve this answer








                          New contributor




                          Jason is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          share|improve this answer



                          share|improve this answer






                          New contributor




                          Jason is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          answered 10 mins ago









                          JasonJason

                          1




                          1




                          New contributor




                          Jason is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.





                          New contributor





                          Jason is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






                          Jason is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.























                              -1














                              In magento all CMS pages have an option of Layout Update XML update .Just Call your Custom code there also add CSS or JS .



                              Admin CMS Pages



                              GOTO ADMIN -> Content -> Pages -> Edit page -> Design -> Layout Update XML


                              add below call



                              <head>
                              <css src="Namespace_YourModule::css/styles.css"/>
                              </head>





                              share|improve this answer
























                              • this works in page layout configuration not in Layout Update XML , hope you checked...

                                – Mohammad Mujassam
                                Jul 21 '16 at 4:44











                              • It is working fine I have tested this code . just remove "Namespace_YourModule::" and set in to "Layout Update XML" and refresh you Cache so you can show in that page only.

                                – Hitesh Vaghasiya
                                Jul 21 '16 at 18:59






                              • 1





                                Please correct the XML data and try again. Element 'head': This element is not expected. Expected is one of ( referenceContainer, container, update, move ). Line: 1 this we will get if we put anything else apart from above four Element. I am using magento 2.0.7

                                – Mohammad Mujassam
                                Jul 22 '16 at 4:40








                              • 1





                                Yeah, this worked for me. Just remember to flush the cache after you change the layout for the cms page to pickup the change.

                                – Dallas Clarke
                                Dec 13 '17 at 3:23
















                              -1














                              In magento all CMS pages have an option of Layout Update XML update .Just Call your Custom code there also add CSS or JS .



                              Admin CMS Pages



                              GOTO ADMIN -> Content -> Pages -> Edit page -> Design -> Layout Update XML


                              add below call



                              <head>
                              <css src="Namespace_YourModule::css/styles.css"/>
                              </head>





                              share|improve this answer
























                              • this works in page layout configuration not in Layout Update XML , hope you checked...

                                – Mohammad Mujassam
                                Jul 21 '16 at 4:44











                              • It is working fine I have tested this code . just remove "Namespace_YourModule::" and set in to "Layout Update XML" and refresh you Cache so you can show in that page only.

                                – Hitesh Vaghasiya
                                Jul 21 '16 at 18:59






                              • 1





                                Please correct the XML data and try again. Element 'head': This element is not expected. Expected is one of ( referenceContainer, container, update, move ). Line: 1 this we will get if we put anything else apart from above four Element. I am using magento 2.0.7

                                – Mohammad Mujassam
                                Jul 22 '16 at 4:40








                              • 1





                                Yeah, this worked for me. Just remember to flush the cache after you change the layout for the cms page to pickup the change.

                                – Dallas Clarke
                                Dec 13 '17 at 3:23














                              -1












                              -1








                              -1







                              In magento all CMS pages have an option of Layout Update XML update .Just Call your Custom code there also add CSS or JS .



                              Admin CMS Pages



                              GOTO ADMIN -> Content -> Pages -> Edit page -> Design -> Layout Update XML


                              add below call



                              <head>
                              <css src="Namespace_YourModule::css/styles.css"/>
                              </head>





                              share|improve this answer













                              In magento all CMS pages have an option of Layout Update XML update .Just Call your Custom code there also add CSS or JS .



                              Admin CMS Pages



                              GOTO ADMIN -> Content -> Pages -> Edit page -> Design -> Layout Update XML


                              add below call



                              <head>
                              <css src="Namespace_YourModule::css/styles.css"/>
                              </head>






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Jul 20 '16 at 14:46









                              Hitesh VaghasiyaHitesh Vaghasiya

                              4711416




                              4711416













                              • this works in page layout configuration not in Layout Update XML , hope you checked...

                                – Mohammad Mujassam
                                Jul 21 '16 at 4:44











                              • It is working fine I have tested this code . just remove "Namespace_YourModule::" and set in to "Layout Update XML" and refresh you Cache so you can show in that page only.

                                – Hitesh Vaghasiya
                                Jul 21 '16 at 18:59






                              • 1





                                Please correct the XML data and try again. Element 'head': This element is not expected. Expected is one of ( referenceContainer, container, update, move ). Line: 1 this we will get if we put anything else apart from above four Element. I am using magento 2.0.7

                                – Mohammad Mujassam
                                Jul 22 '16 at 4:40








                              • 1





                                Yeah, this worked for me. Just remember to flush the cache after you change the layout for the cms page to pickup the change.

                                – Dallas Clarke
                                Dec 13 '17 at 3:23



















                              • this works in page layout configuration not in Layout Update XML , hope you checked...

                                – Mohammad Mujassam
                                Jul 21 '16 at 4:44











                              • It is working fine I have tested this code . just remove "Namespace_YourModule::" and set in to "Layout Update XML" and refresh you Cache so you can show in that page only.

                                – Hitesh Vaghasiya
                                Jul 21 '16 at 18:59






                              • 1





                                Please correct the XML data and try again. Element 'head': This element is not expected. Expected is one of ( referenceContainer, container, update, move ). Line: 1 this we will get if we put anything else apart from above four Element. I am using magento 2.0.7

                                – Mohammad Mujassam
                                Jul 22 '16 at 4:40








                              • 1





                                Yeah, this worked for me. Just remember to flush the cache after you change the layout for the cms page to pickup the change.

                                – Dallas Clarke
                                Dec 13 '17 at 3:23

















                              this works in page layout configuration not in Layout Update XML , hope you checked...

                              – Mohammad Mujassam
                              Jul 21 '16 at 4:44





                              this works in page layout configuration not in Layout Update XML , hope you checked...

                              – Mohammad Mujassam
                              Jul 21 '16 at 4:44













                              It is working fine I have tested this code . just remove "Namespace_YourModule::" and set in to "Layout Update XML" and refresh you Cache so you can show in that page only.

                              – Hitesh Vaghasiya
                              Jul 21 '16 at 18:59





                              It is working fine I have tested this code . just remove "Namespace_YourModule::" and set in to "Layout Update XML" and refresh you Cache so you can show in that page only.

                              – Hitesh Vaghasiya
                              Jul 21 '16 at 18:59




                              1




                              1





                              Please correct the XML data and try again. Element 'head': This element is not expected. Expected is one of ( referenceContainer, container, update, move ). Line: 1 this we will get if we put anything else apart from above four Element. I am using magento 2.0.7

                              – Mohammad Mujassam
                              Jul 22 '16 at 4:40







                              Please correct the XML data and try again. Element 'head': This element is not expected. Expected is one of ( referenceContainer, container, update, move ). Line: 1 this we will get if we put anything else apart from above four Element. I am using magento 2.0.7

                              – Mohammad Mujassam
                              Jul 22 '16 at 4:40






                              1




                              1





                              Yeah, this worked for me. Just remember to flush the cache after you change the layout for the cms page to pickup the change.

                              – Dallas Clarke
                              Dec 13 '17 at 3:23





                              Yeah, this worked for me. Just remember to flush the cache after you change the layout for the cms page to pickup the change.

                              – Dallas Clarke
                              Dec 13 '17 at 3:23


















                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Magento Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f126646%2fmagento2-how-to-add-different-custom-css-file-on-specific-cms-pages%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              What other Star Trek series did the main TNG cast show up in?

                              Berlina muro

                              Berlina aerponto