Magento – add static block on top of header

magento2php-7static-block

I am trying to customize Magento top header with some custom static block and also want to change and relocate existing link and icon like wish-list.
I created static block for top-header social icon and try to add this default.xml file. But unlucky .

    <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\Cms\Block\Block" name="header_socail_link"  after="header.panel">
                <arguments>
                    <argument name="block_id" xsi:type="string">header_socail_link</argument>
                </arguments>
            </block> 
        </referenceContainer>
        <referenceBlock name="logo">
            <arguments>
                <argument name="logo_file" xsi:type="string">images/astrokapoor_logo.png</argument>
                <argument name="logo_img_width" xsi:type="number">180</argument>
                <argument name="logo_img_height" xsi:type="number">69</argument>
            </arguments>
        </referenceBlock>
         <referenceContainer name="main.content">
            <block class="Magento\Framework\View\Element\Template" name="skip_to_content.target" before="-" template="Magento_Theme::html/skiptarget.phtml">
                <arguments>
                    <argument name="target_id" xsi:type="string">contentarea</argument>
                </arguments>
            </block>
        </referenceContainer>        
        <referenceContainer name="footer-container">
            <container name="footer" as="footer" label="Page Footer" htmlTag="div" htmlClass="footer content">
                <block class="Magento\Store\Block\Switcher" name="store_switcher" as="store_switcher" template="Magento_Store::switch/stores.phtml"/>
                <block class="Magento\Framework\View\Element\Html\Links" name="footer_links">
                    <arguments>
                        <argument name="css_class" xsi:type="string">footer links</argument>
                    </arguments>
                </block>
                <block class="Magento\Theme\Block\Html\Footer" name="copyright" template="Magento_Theme::html/copyright.phtml"/>
                <block class="Magento\Framework\View\Element\Template" name="report.bugs" template="Magento_Theme::html/bugreport.phtml" />
            </container>
        </referenceContainer>
        <!--<move element="top.links" destination="header-wrapper" after="logo" />!-->
        <move element="wish-list-link" destination="panel.top.links" />
        <referenceBlock name="header" remove="true" />

    </body>
</page>

similarly I want add currency logo on top and wish-list logo after cart item.please see screenshot .its my exact requirement.any help
enter image description here

Best Answer

Try this:

<referenceContainer name="header-wrapper">
        <block class="Magento\Framework\View\Element\Template" before="minicart" name="header.wishlist" template="Magento_Wishlist::link.phtml" />
    </referenceContainer>

Now create new file in your theme like this: /{theme Pcakage}/{theme name}/Magento_Wishlist/templates/link.phtmlAnd add this code in that file:

<div>
    <a href="<?php  echo $this->getUrl('wishlist') ?>" class="action towishlist" data-action="add-to-wishlist"><span><?php echo __('Add to Wish List');?> </span></a>
</div>

Now flush the cache.

Related Topic