Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMS Page with <head> in layout update xml #4454

Closed
zhiyicai opened this issue May 10, 2016 · 21 comments
Closed

CMS Page with <head> in layout update xml #4454

zhiyicai opened this issue May 10, 2016 · 21 comments
Labels
Area: Frontend bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@zhiyicai
Copy link

zhiyicai commented May 10, 2016

Hello all,

I was able before to include custom css in my cms page using the Layout update xml field with this

<head>
    <css src="css/home.css"/>
</head>

But since the v2.0.4 I have the following message whenever I try to save my page
"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"

How can I do no to include custom css files in my cms pages?

2016-05-10 22 20 35

@maksek maksek added the Layout label May 10, 2016
@duhon duhon added the PS label Jun 8, 2016
@devonto
Copy link

devonto commented Aug 23, 2016

Also facing the same issue and require to be able to add in custom canonical URLs from the head.

@djpaoloc
Copy link

djpaoloc commented Oct 6, 2016

same problem with <body> in layout update xml

@PieterCappelle
Copy link
Contributor

Having same problem to add breadcrumto CMS page. This was working in M1.

@MomotenkoNatalia MomotenkoNatalia added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development and removed question labels Dec 13, 2016
@MomotenkoNatalia
Copy link
Contributor

Hi All!

We already have an internal ticket to solve this problem - MAGETWO-60727

@devonto
Copy link

devonto commented Dec 13, 2016

Thanks, any estimation on when a workaround may be released to allow us to implement it immediately?

@MomotenkoNatalia
Copy link
Contributor

@devonto Unfortunatly, currently we have no easy and right way to include the css to the specific page. But like a temporary solution you can try to follow the our devdocs documentation - http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/css-topics/css-themes.html OR just to add link for css right to the content description. This is not very good solution, but it works.

@franckgarnier21
Copy link

franckgarnier21 commented Mar 27, 2017

I find a workaround for this bug : http://magento.stackexchange.com/questions/126646/magento2-how-to-add-different-custom-css-file-on-specific-cms-pages/166322#166322

The root cause is here : vendor/magento/framework/View/Layout/etc/page_layout.xsd

Need to add :

    <xs:include schemaLocation="urn:magento:framework:View/Layout/etc/head.xsd"/>
    <xs:include schemaLocation="urn:magento:framework:View/Layout/etc/body.xsd"/>

            <xs:element name="head" type="headType" minOccurs="0" maxOccurs="unbounded"/>
            <xs:element name="body" type="bodyType" minOccurs="0" maxOccurs="unbounded"/>

Complete file :

<?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>

I do not test the side effect. But it works for me.

@Khaleel
Copy link

Khaleel commented Apr 19, 2017

How can I use the code to add:


<?xml version="1.0"?>
<page
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <meta name="robots" content="NOINDEX, NOFOLLOW"/>
        <link rel="canonical" href="/sale" />
    </head>
</page>

@magento-engcom-team magento-engcom-team added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Area: Frontend Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed labels Sep 11, 2017
@franckgarnier21
Copy link

Any news about this issue ? Is it solved in Magento 2.2 ?

@magento-engcom-team
Copy link
Contributor

@zhiyicai, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.
We tested the issue on 2.3.0-dev, 2.2.0, 2.1.9

@magento-engcom-team magento-engcom-team added the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label Oct 13, 2017
@magento-engcom-team magento-engcom-team added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Oct 13, 2017
@franckgarnier21
Copy link

franckgarnier21 commented Oct 13, 2017

Can you share the commit which solve this issue ? I am interesting to know how you fix this

@Krapulat
Copy link

I confirm this bug in Magento 2.2.2.

@franckgarnier21 Your workaround works fine!

@magento-engcom-team
Copy link
Contributor

Hi @zhiyicai. Thank you for your report.
The issue has been fixed in #13817 by @cedricziel in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.4 release.

@magento-engcom-team
Copy link
Contributor

Hi @zhiyicai. Thank you for your report.
The issue has been fixed in #14205 by @dimonovp in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Mar 21, 2018
@orbitrod
Copy link

orbitrod commented May 8, 2018

I have 2.3.0, but I don't see this fix. Has it been rolled out to 2.3.0 yet?

@sanderjongsma
Copy link
Contributor

@orbitrod 2.3.0 is not released yet. I think you have the 2.2.3 release, which indeed does not contain this fix.

@orbitrod
Copy link

orbitrod commented May 9, 2018

@sanderjongsma Something is wrong with my eyes, yes you are right, I have 2.2.3.

@jove4015
Copy link

jove4015 commented Sep 5, 2018

I'm just installing version 2.2.5 and this issue still appears to be there. I double checked and I am positive I am on 2.2.5. Has this possibly regressed since 2.2.4?

@bdenham
Copy link

bdenham commented Nov 1, 2018

same problem with <body> in layout update xml

@djpaoloc, can you provide an example of how you are using as a layout instruction to update your file? I would like to add this to the docs that I'm working on updating. Thanks!

@bdenham
Copy link

bdenham commented Nov 1, 2018

I'm just installing version 2.2.5 and this issue still appears to be there. I double checked and I am positive I am on 2.2.5. Has this possibly regressed since 2.2.4?

@jove4015, did you ever figure out or confirm what was happening in version 2.2.5?

@prakashsaran
Copy link

prakashsaran commented Jan 19, 2019

i have a idea we can do this following way
app/design/frontend/<your_vendor_name>/<your_theme_name>/Magento_Catalog/layout/catalog_category_view_id_.xml
in this xml file put your code
it is work for single category view page

magento-cicd2 pushed a commit that referenced this issue Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Frontend bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests