I have a theme that extends luma. It is called "Custom Dev" and it is in "adventist_store" folder. I want to replace the logo at the top with a block. (I'm doing this because I want to have two logos next to each other on one store and I want to center the logos) bassically I want to replace the "header content" class on the store page with my own block, or have the block go inside "header content"
I have almost been able to do this by attemping to follow this: https://www.atwix.com/magento-2/adding-blocks-to-head-section/ maybe I'm not understanding it.
Here's parent theme:
vendor/magento/theme-frontend-luma/Magento_Theme/layout/default.xml
<?xml version="1.0"?>
<!--
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="header.panel">
<block class="Magento\Framework\View\Element\Html\Links" name="header.links">
<arguments>
<argument name="css_class" xsi:type="string">header links</argument>
</arguments>
</block>
</referenceContainer>
<referenceBlock name="logo">
<arguments>
<argument name="logo_img_width" xsi:type="number">148</argument>
<argument name="logo_img_height" xsi:type="number">43</argument>
</arguments>
</referenceBlock>
<referenceContainer name="footer">
<block class="Magento\Store\Block\Switcher" name="store_switcher" as="store_switcher" after="footer_links" template="switch/stores.phtml"/>
</block>
</referenceContainer>
<referenceBlock name="report.bugs" remove="true"/>
<move element="copyright" destination="before.body.end"/>
</body>
</page>
And I'm extending it like so:
app/design/frontend/Magento/adventist_store/Magento_Theme/templates/header_template.phtml
<?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('block_header_custom')->toHtml();?>
app/design/frontend/Magento/adventist_store/Magento_Theme/layout/default.xml
<?xml version="1.0"?>
<!--
/**
* Copyright � 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="head.additional">
<block class="Magento\Cms\Block\Block" name="block-header" after="header">
<arguments>
<argument name="block_id" xsi:type="string">block_header_custom</argument>
<argument name="template" xsi:type="string">%Magento_Theme::header_template.phtml%</argument>
</arguments>
</block>
</referenceBlock>
<referenceContainer name="header.panel" remove="true"/>
<referenceBlock name="logo" remove="true"/>
<referenceContainer name="footer">
<block class="Magento\Cms\Block\Block" name="block-footer" after="footer_links">
<arguments>
<argument name="block_id" xsi:type="string">block_footer_custom</argument>
<argument name="template" xsi:type="string">%Magento_Theme::footer_template.phtml%</argument>
</arguments>
</block>
<referenceBlock name="report.bugs" remove="true"/>
</referenceContainer>
</body>
</page>
However this puts the logos above "header content" right after the tag:
<body data-container="body" . . .
I have to remove the header.panel: <referenceContainer name="header.panel" remove="true"/>
otherwise it appears as a grey thing between my logos and "header content" I would rather not have to remove the grey header.panel and just have my block inside the "header content" class. Thanks.
Best Answer
Thanks Aaron Allen. I added my block to the "header-wrapper" container instead of "head.additional" and it works.
So I changed this:
<referenceBlock name="head.additional">
to this:
<referenceBlock name="header-wrapper">
I was not aware that you could do that directly to the classes you see in html divs and I didn't realize it was already doing that but just using a "." in between the classes:
http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/layouts/xml-manage.html