Add class to body in CMS page (with layout update xml from admin panel) Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?CMS XML Handles for Layout UpdatesPlease correct the XML data and try again. Element 'referenceBlock': This element is not expectedMagento 2 Add block to custom layout via admin panel widgetMagento 2 - Admin Layout XML - Update Template and change block type for specific categoryMagento 2 “Layout Update XML” in Admin not workingMagento 2 custom layout add body classMagento 2 CMS page add custom breadcrumbsMagento2: Add JS from Admin CMS page Design “layout update XML”How to set canonical url for homepage in Magento 2.2Magento 2 | Add NOINDEX, NOFOLLOW to CMS page using Layout Update XML
How do I make this wiring inside cabinet safer?
A term for a woman complaining about things/begging in a cute/childish way
Does the Weapon Master feat grant you a fighting style?
Disembodied hand growing fangs
How would a mousetrap for use in space work?
Is grep documentation about ignoring case wrong, since it doesn't ignore case in filenames?
An adverb for when you're not exaggerating
Performance gap between bool std:vector and array
Do I really need to have a message in a novel to appeal to readers?
Denied boarding although I have proper visa and documentation. To whom should I make a complaint?
Why do we need to use the builder design pattern when we can do the same thing with setters?
What does it mean that physics no longer uses mechanical models to describe phenomena?
How could we fake a moon landing now?
Most bit efficient text communication method?
How to install press fit bottom bracket into new frame
What's the meaning of "fortified infraction restraint"?
Is there any word for a place full of confusion?
ArcGIS Pro Python arcpy.CreatePersonalGDB_management
Are all finite dimensional hilbert spaces isomorphic to spaces with Euclidean norms?
Can a new player join a group only when a new campaign starts?
How to tell that you are a giant?
Why is Nikon 1.4g better when Nikon 1.8g is sharper?
Do any jurisdictions seriously consider reclassifying social media websites as publishers?
Did Deadpool rescue all of the X-Force?
Add class to body in CMS page (with layout update xml from admin panel)
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?CMS XML Handles for Layout UpdatesPlease correct the XML data and try again. Element 'referenceBlock': This element is not expectedMagento 2 Add block to custom layout via admin panel widgetMagento 2 - Admin Layout XML - Update Template and change block type for specific categoryMagento 2 “Layout Update XML” in Admin not workingMagento 2 custom layout add body classMagento 2 CMS page add custom breadcrumbsMagento2: Add JS from Admin CMS page Design “layout update XML”How to set canonical url for homepage in Magento 2.2Magento 2 | Add NOINDEX, NOFOLLOW to CMS page using Layout Update XML
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm trying to add a class to body (cms-page-aboutus) via layout XML update inside Magento 2 admin panel.
I know that CMS pages already add a body I could use to target my page, but I need to target multiple CMS pages for several languages at once (cms-about-us, cms-acerca-de, cms-a-propos).
I don't want to duplicate CSS, therefore a common class would be best.
I have tried the following:
<body>
<attribute name="class" value="body-class" />
</body>
But it fails to save in admin panel:
Please correct the XML data and try again. Element 'body': This element is not expected. Expected is one of ( referenceContainer, container, update, move ). Line: 2
Since it seems that only "update" keyword is allowed, I tried using it to add a new handle:
<update handle="cms_page_aboutus"/>
and then created the file:
app/design/<>/<>/Magento_Cms/layout/cms_page_aboutus.xml
with the body update within, but it does not work.
Any idea?
magento2 magento-2.1 layout cms
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I'm trying to add a class to body (cms-page-aboutus) via layout XML update inside Magento 2 admin panel.
I know that CMS pages already add a body I could use to target my page, but I need to target multiple CMS pages for several languages at once (cms-about-us, cms-acerca-de, cms-a-propos).
I don't want to duplicate CSS, therefore a common class would be best.
I have tried the following:
<body>
<attribute name="class" value="body-class" />
</body>
But it fails to save in admin panel:
Please correct the XML data and try again. Element 'body': This element is not expected. Expected is one of ( referenceContainer, container, update, move ). Line: 2
Since it seems that only "update" keyword is allowed, I tried using it to add a new handle:
<update handle="cms_page_aboutus"/>
and then created the file:
app/design/<>/<>/Magento_Cms/layout/cms_page_aboutus.xml
with the body update within, but it does not work.
Any idea?
magento2 magento-2.1 layout cms
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Why you need to add specific class in body, in CMS page you can find already one specific class. i.e: cms-aboutus
– hweb87
May 1 '18 at 11:33
add a comment |
I'm trying to add a class to body (cms-page-aboutus) via layout XML update inside Magento 2 admin panel.
I know that CMS pages already add a body I could use to target my page, but I need to target multiple CMS pages for several languages at once (cms-about-us, cms-acerca-de, cms-a-propos).
I don't want to duplicate CSS, therefore a common class would be best.
I have tried the following:
<body>
<attribute name="class" value="body-class" />
</body>
But it fails to save in admin panel:
Please correct the XML data and try again. Element 'body': This element is not expected. Expected is one of ( referenceContainer, container, update, move ). Line: 2
Since it seems that only "update" keyword is allowed, I tried using it to add a new handle:
<update handle="cms_page_aboutus"/>
and then created the file:
app/design/<>/<>/Magento_Cms/layout/cms_page_aboutus.xml
with the body update within, but it does not work.
Any idea?
magento2 magento-2.1 layout cms
I'm trying to add a class to body (cms-page-aboutus) via layout XML update inside Magento 2 admin panel.
I know that CMS pages already add a body I could use to target my page, but I need to target multiple CMS pages for several languages at once (cms-about-us, cms-acerca-de, cms-a-propos).
I don't want to duplicate CSS, therefore a common class would be best.
I have tried the following:
<body>
<attribute name="class" value="body-class" />
</body>
But it fails to save in admin panel:
Please correct the XML data and try again. Element 'body': This element is not expected. Expected is one of ( referenceContainer, container, update, move ). Line: 2
Since it seems that only "update" keyword is allowed, I tried using it to add a new handle:
<update handle="cms_page_aboutus"/>
and then created the file:
app/design/<>/<>/Magento_Cms/layout/cms_page_aboutus.xml
with the body update within, but it does not work.
Any idea?
magento2 magento-2.1 layout cms
magento2 magento-2.1 layout cms
edited Mar 21 '17 at 9:43
Matthéo Geoffray
2,10311341
2,10311341
asked Mar 21 '17 at 9:29
davidvelilladavidvelilla
1465
1465
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Why you need to add specific class in body, in CMS page you can find already one specific class. i.e: cms-aboutus
– hweb87
May 1 '18 at 11:33
add a comment |
Why you need to add specific class in body, in CMS page you can find already one specific class. i.e: cms-aboutus
– hweb87
May 1 '18 at 11:33
Why you need to add specific class in body, in CMS page you can find already one specific class. i.e: cms-aboutus
– hweb87
May 1 '18 at 11:33
Why you need to add specific class in body, in CMS page you can find already one specific class. i.e: cms-aboutus
– hweb87
May 1 '18 at 11:33
add a comment |
1 Answer
1
active
oldest
votes
I don't think you can target body in any layout xml and thus not in admin too as body is above the root element.
It seems to be set in this file app/code/Magento/Theme/view/base/templates/root.phtml:
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<!doctype html>
<html <?php /* @escapeNotVerified */ echo $htmlAttributes ?>>
<head <?php /* @escapeNotVerified */ echo $headAttributes ?>>
<?php /* @escapeNotVerified */ echo $requireJs ?>
<?php /* @escapeNotVerified */ echo $headContent ?>
<?php /* @escapeNotVerified */ echo $headAdditional ?>
</head>
<body class="preload" data-container="body" data-mage-init='"loaderAjax": , "loader": "icon": "<?php /* @escapeNotVerified */ echo $loaderIcon; ?>"' <?php /* @escapeNotVerified */ echo $bodyAttributes ?>>
<?php /* @escapeNotVerified */ echo $layoutContent ?>
</body>
</html>
If you overwrite that in your theme you can set a class as shown above.
As you can see there are $bodyAttributes too that might enable you to set a class. But I couldn't figure out yet if and how we could set those attributes.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f165350%2fadd-class-to-body-in-cms-page-with-layout-update-xml-from-admin-panel%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I don't think you can target body in any layout xml and thus not in admin too as body is above the root element.
It seems to be set in this file app/code/Magento/Theme/view/base/templates/root.phtml:
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<!doctype html>
<html <?php /* @escapeNotVerified */ echo $htmlAttributes ?>>
<head <?php /* @escapeNotVerified */ echo $headAttributes ?>>
<?php /* @escapeNotVerified */ echo $requireJs ?>
<?php /* @escapeNotVerified */ echo $headContent ?>
<?php /* @escapeNotVerified */ echo $headAdditional ?>
</head>
<body class="preload" data-container="body" data-mage-init='"loaderAjax": , "loader": "icon": "<?php /* @escapeNotVerified */ echo $loaderIcon; ?>"' <?php /* @escapeNotVerified */ echo $bodyAttributes ?>>
<?php /* @escapeNotVerified */ echo $layoutContent ?>
</body>
</html>
If you overwrite that in your theme you can set a class as shown above.
As you can see there are $bodyAttributes too that might enable you to set a class. But I couldn't figure out yet if and how we could set those attributes.
add a comment |
I don't think you can target body in any layout xml and thus not in admin too as body is above the root element.
It seems to be set in this file app/code/Magento/Theme/view/base/templates/root.phtml:
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<!doctype html>
<html <?php /* @escapeNotVerified */ echo $htmlAttributes ?>>
<head <?php /* @escapeNotVerified */ echo $headAttributes ?>>
<?php /* @escapeNotVerified */ echo $requireJs ?>
<?php /* @escapeNotVerified */ echo $headContent ?>
<?php /* @escapeNotVerified */ echo $headAdditional ?>
</head>
<body class="preload" data-container="body" data-mage-init='"loaderAjax": , "loader": "icon": "<?php /* @escapeNotVerified */ echo $loaderIcon; ?>"' <?php /* @escapeNotVerified */ echo $bodyAttributes ?>>
<?php /* @escapeNotVerified */ echo $layoutContent ?>
</body>
</html>
If you overwrite that in your theme you can set a class as shown above.
As you can see there are $bodyAttributes too that might enable you to set a class. But I couldn't figure out yet if and how we could set those attributes.
add a comment |
I don't think you can target body in any layout xml and thus not in admin too as body is above the root element.
It seems to be set in this file app/code/Magento/Theme/view/base/templates/root.phtml:
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<!doctype html>
<html <?php /* @escapeNotVerified */ echo $htmlAttributes ?>>
<head <?php /* @escapeNotVerified */ echo $headAttributes ?>>
<?php /* @escapeNotVerified */ echo $requireJs ?>
<?php /* @escapeNotVerified */ echo $headContent ?>
<?php /* @escapeNotVerified */ echo $headAdditional ?>
</head>
<body class="preload" data-container="body" data-mage-init='"loaderAjax": , "loader": "icon": "<?php /* @escapeNotVerified */ echo $loaderIcon; ?>"' <?php /* @escapeNotVerified */ echo $bodyAttributes ?>>
<?php /* @escapeNotVerified */ echo $layoutContent ?>
</body>
</html>
If you overwrite that in your theme you can set a class as shown above.
As you can see there are $bodyAttributes too that might enable you to set a class. But I couldn't figure out yet if and how we could set those attributes.
I don't think you can target body in any layout xml and thus not in admin too as body is above the root element.
It seems to be set in this file app/code/Magento/Theme/view/base/templates/root.phtml:
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<!doctype html>
<html <?php /* @escapeNotVerified */ echo $htmlAttributes ?>>
<head <?php /* @escapeNotVerified */ echo $headAttributes ?>>
<?php /* @escapeNotVerified */ echo $requireJs ?>
<?php /* @escapeNotVerified */ echo $headContent ?>
<?php /* @escapeNotVerified */ echo $headAdditional ?>
</head>
<body class="preload" data-container="body" data-mage-init='"loaderAjax": , "loader": "icon": "<?php /* @escapeNotVerified */ echo $loaderIcon; ?>"' <?php /* @escapeNotVerified */ echo $bodyAttributes ?>>
<?php /* @escapeNotVerified */ echo $layoutContent ?>
</body>
</html>
If you overwrite that in your theme you can set a class as shown above.
As you can see there are $bodyAttributes too that might enable you to set a class. But I couldn't figure out yet if and how we could set those attributes.
answered Mar 21 '17 at 10:01
sterossteros
859730
859730
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f165350%2fadd-class-to-body-in-cms-page-with-layout-update-xml-from-admin-panel%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Why you need to add specific class in body, in CMS page you can find already one specific class. i.e: cms-aboutus
– hweb87
May 1 '18 at 11:33